Jump to content

Recommended Posts

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 :)

Link to comment
https://forums.phpfreaks.com/topic/91941-php-echojavascript/
Share on other sites

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>

Link to comment
https://forums.phpfreaks.com/topic/91941-php-echojavascript/#findComment-470868
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/91941-php-echojavascript/#findComment-470888
Share on other sites

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);">';

Link to comment
https://forums.phpfreaks.com/topic/91941-php-echojavascript/#findComment-470910
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.