|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Javascript - Jump from if to else
Hey Guys, If i've this sort of code
Code:
if(x==2){
y = somefunc(x);
if (y == 25){
alert("Valid");
}else{
alert("not valid");
}
}else{
alert("not valid");
}
Instead of having 2 lines of alert("not valid"), can I make the loop jump to the else of the original if statement?
__________________
~~==~~ Whoever said nothing is impossible never tried pushing a revolving door ~~==~~ |
|
#2
|
|||
|
|||
|
best option is you can define that on one function and on else part you can call that function again
may be it will work, coz there is no goto or jump in javascript thankx Last edited by kirank : August 24th, 2009 at 09:01 AM. |
|
#3
|
|||
|
|||
|
actually probably the best thing to do would be to change somefunc to check the first if part. then you can do away with the whole if(x==2) stuff. just make somefunc check if(x==2) and if not return false.
|
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Client Side Things > Javascript - Jump from if to else |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|