|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Javascript
Hey all, i've pulled out a segment of a checkForm function i am using that is giving me problems.
The form we are using, if a user chooses option 1 or 3 in field "description" then i dont want to check for the selection for "type" im not necessarily tied to using the switch, but its the last thing i tried. any help would be great! Code:
<% fieldName = "description"
errorMessage = "Description is Required" %>
var n;
n = frm.<% = fieldName %>.selectedIndex;
switch(n)
{
case 1:
proceedCheck = false
case 2:
proceedCheck = true
case 3:
proceedCheck = false
case else:
alert('Shouldnt land here');
}
if (proceedCheck == true)
{
<% fieldName = "type"
errorMessage = "Payment Type is Required" %>
if (frm.<% = fieldName %>.selectedIndex == 0)
{
alert("<% = errorMessage %>");
frm.<% = fieldName %>.focus();
return false;
}
}
|
|
#2
|
|||
|
|||
|
What's Not Working?
I can't tell from your message what is not working. If you could provide more details, as well as a "View Source" from a broken page, that might help.
|
|
#3
|
||||
|
||||
|
you're on the right direction, just missing the "break" keyword:
Code:
switch(n)
{
case 1:
proceedCheck = false;
break;
case 2:
proceedCheck = true;
break;
case 3:
proceedCheck = false;
break;
case else:
alert('Shouldnt land here');
}
without break, the switch command will simply go to the last "case" block, always. |
![]() |
| Viewing: ASP Free Forums > Programming > HTML, JavaScript And CSS Help > Javascript |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|