Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: Help with OnChange in a Select Menu


Message #1 by anne.do@c... on Tue, 10 Dec 2002 11:58:12 -0500
	I don't really understand the question(s), but here are some points
for you :
1) you wrote
eval(targ+".location=3D'"+selObj.options[selObj.selectedIndex].value+"'"
);
If targ is always "parent", you could very well use
parent.location =3D .....
Only use eval() when there's no other solution because debugging
instructions "packaged" within strings isn't easy.
Otherwise, try
eval(targ).location =3D .....
to see if this works.

2) I feel that the instruction
if (restore) selObj.selectedIndex=3D0;
will never be executed because you change the parent's locate before 
this
instruction.


> -----Message d'origine-----
> De : anne.do@c... [mailto:anne.do@c...]
> Envoy=C3=A9 : mardi 10 d=C3=A9cembre 2002 17:58
> =C3=80 : javascript
> Objet : [javascript] Help with OnChange in a Select Menu
>
>
> I have a form in which I want the action page to be dependent
> on a select
> box.  The <script> below only redirects but does not do a
> form submit to the
> action page.  I also want the two checkbox values (if they
> are checked) to
> also submit values to the selected action page.  Each select
> option will
> submit the form to a different page.  Please help? The script
> below can be
> replaced if need since it doesn't do a full form submit.
>
> Also, for the fourth select option "select All" I want to
> have all checked
> boxes with name "test" checked when this option is chosen. 
>
> <script language=3D"javascript">
> function MM_jumpMenu(targ,selObj,restore){ //v3.0
> eval(targ+".location=3D'"+selObj.options[selObj.selectedIndex].v
> alue+"'");
> if (restore) selObj.selectedIndex=3D0;}
> </script>
>
>
> <form name=3D"jumpMenu">
>       <select name=3D"menu1" 
onChange=3D"MM_jumpMenu('parent',this,1)">
>         <option value=3D"" >Select One Below</option>
>         <option value=3D"Page1.cfm">Some Page</option>
>         <option value=3D"page2.cfm">Another Page</option>
>         <option value=3D"page3.cfm">Page 3</option>
> 	<option value=3D"? ">Select All</option>
>       </select>
>
> <input type=3D"checkbox" name=3D"test" value=3D"test">
> <input type=3D"checkbox" name=3D"test" value=3D"Next">
>
> </form>
>
>

  Return to Index