yandoo Posted February 19, 2008 Share Posted February 19, 2008 Hi there , I have a basic form with 2 drop downs....both are identical.....They are setup so that the option the user selects, that user is hyperlinked to that page.... My problem is that on the second drop down (which is identical) has a conditional statement stating that if user ha access level 2 then display!! The conditional works fine....the problem is that the 2nd drop down now doent hyperlink to option chosen at all...yet the first one does.... This leads me to the concluion that echos for the 2nd drop down arnt working??? Heres my 2 drop downs in code form: <form name="AutoListBox" id="AutoListBox"> <td> <div align="left"> <select name="ListBoxURL" size="1" language="javascript" onchange="gotoLink(this.form);"> <option value="animal.php"> Animal</option> <option value="customer.php">Customer</option> <option value="appointment.php">Appointment</option> <option selected="selected"> -- Select -- </option> </select> </div></td></form> // Show IF Conditional region1 //echo @$row_user['Username']; if (@$row_user_conditional['Access'] == "2") { echo "Admin: </div></td>"; echo '<td height="23" valign="top">'; echo'<form name="AutoListBox" id="AutoListBox">'; echo '<div align="left">'; echo'<select name="select" size="1" language="javascript" onchange="gotoLink(this.form);">'; echo'<option value="animal.php"> Animal</option>'; echo'<option value="customer.php">Customer</option>'; echo'<option value="User.php">User</option>'; echo'<option value="appointment.php">Appointment</option>'; echo'<option selected="selected"> -- Select -- </option>'; echo"</select>"; echo"</div>"; echo"</form>"; } // endif Conditional region1 ?> Im thinking (hoping) this is something that can be easily fixed.... any help would be sweet! Thank You Quote Link to comment https://forums.phpfreaks.com/topic/91941-php-echojavascript/ Share on other sites More sharing options...
craygo Posted February 19, 2008 Share Posted February 19, 2008 you can easily right click on your page an select view code to see if the echo's are working. Quote Link to comment https://forums.phpfreaks.com/topic/91941-php-echojavascript/#findComment-470838 Share on other sites More sharing options...
yandoo Posted February 19, 2008 Author Share Posted February 19, 2008 Hi there, The echos work as the 2nd drop down appears (when i access level 2). It just that they dont link to other page like the first drop down?? Ithought the IF conditional was stopping it in some way?? Help Quote Link to comment https://forums.phpfreaks.com/topic/91941-php-echojavascript/#findComment-470856 Share on other sites More sharing options...
rhodesa Posted February 19, 2008 Share Posted February 19, 2008 What is the JavaScript for gotolink()? Also, it seems like there should only be 1 drop down with more items if the user is an admin like so: <td> <form name="AutoListBox" id="AutoListBox"> <?php if(@$row_user_conditional['Access'] == "2") echo "Admin: "; ?> <div align="left"> <select name="ListBoxURL" size="1" language="javascript" onchange="gotoLink(this.form);"> <option value="animal.php"> Animal</option> <option value="customer.php">Customer</option> <?php if(@$row_user_conditional['Access'] == "2") { ?> <option value="User.php">User</option> <?php } ?> <option value="appointment.php">Appointment</option> <option selected="selected"> -- Select -- </option> </select> </div> </form> </td> Quote Link to comment https://forums.phpfreaks.com/topic/91941-php-echojavascript/#findComment-470868 Share on other sites More sharing options...
craygo Posted February 19, 2008 Share Posted February 19, 2008 maybe try renaming the forms so they are different. Quote Link to comment https://forums.phpfreaks.com/topic/91941-php-echojavascript/#findComment-470879 Share on other sites More sharing options...
yandoo Posted February 19, 2008 Author Share Posted February 19, 2008 Hi there, thanks for reply! The javascript is basic code to apply hyperlink to drop down.....At the moment, both drop downs offer the same options and links.... Also i may add...for testing purposes i have created a 3rd drop down with different options hyperlinking to appropriate pages.....again this 3rd drop down works!!! It is only the 2nd drop down with the IF statement conditional on it.... I forgot to add the code thats in the HEAD section of page: <script language="JavaScript"> <!-- function gotoLink(form) { var OptionIndex=form.ListBoxURL.selectedIndex; parent.location = form.ListBoxURL.options[OptionIndex].value;} //--> </script> What you think?? Thank You Quote Link to comment https://forums.phpfreaks.com/topic/91941-php-echojavascript/#findComment-470888 Share on other sites More sharing options...
yandoo Posted February 19, 2008 Author Share Posted February 19, 2008 Dont know if this helps but can see error on IE saying: "ListBoxURL.selectedindex" is null or not an object.... HHmm Hope that helps Thanks Quote Link to comment https://forums.phpfreaks.com/topic/91941-php-echojavascript/#findComment-470897 Share on other sites More sharing options...
yandoo Posted February 19, 2008 Author Share Posted February 19, 2008 Also tried renaming forms and same result... With all these coincidences surely it must be the php IF statement....effecting it?? Quote Link to comment https://forums.phpfreaks.com/topic/91941-php-echojavascript/#findComment-470908 Share on other sites More sharing options...
rhodesa Posted February 19, 2008 Share Posted February 19, 2008 Just as I expected. It's looking for a form element called ListBoxURL, but in your second drop down, you named it 'select'. Also, remove the language="javascript", that should not be there. Find echo'<select name="select" size="1" language="javascript" onchange="gotoLink(this.form);">'; replace with echo'<select name="ListBoxURL" size="1" onchange="gotoLink(this.form);">'; Quote Link to comment https://forums.phpfreaks.com/topic/91941-php-echojavascript/#findComment-470910 Share on other sites More sharing options...
yandoo Posted February 19, 2008 Author Share Posted February 19, 2008 You are a Gentleman!!! Thank you very much indeed!! I think i should have break as i should have spotted that.. Thanks again Very Happy Member Quote Link to comment https://forums.phpfreaks.com/topic/91941-php-echojavascript/#findComment-470923 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.