Jump to content

PHP listbox help


frozenlight777

Recommended Posts

I'm fairly new to PHP and was wondering how to generate a calender from a list box when it's clicked.

for example i have the following code...

 

<form name="form1" method="post" action="">

<span> Search By: </span>

<select size=1 name=list>

<option value="fname">First Name</option>

<option value="lname">Last Name</option>

<option value="drange">Date Range</option>

</select>

  <span class="style4">Enter Name</span>

  <input name="q" type="text" id="q" value="<?php echo $q; ?>">

  <input type="submit" name="Submit" value="Look Up Hours">

</form>

 

I want to make a calender or two appear when the "Date Range" item is clicked in the list box. Not quite sure how.

Link to comment
Share on other sites

the javascript would be something like this:

 

in the form, where you have the <select name="listbox" ... > add "onchange = checkListBox();"

 

something like this:

<select name="myListBox" id="myListBox" onchange = checkListBox(); >

 

then you can have this function either on the web page or in a linked .js file:

 

function checkListBox {
   if(document.getElementById("myListBox").value = "3rd item") {
   //make text box visible or just add text to an empty <span> or <p> using innerHTML
   }
}

 

 

you should look up the how the listbox works and how JS might interact with them, this example might not be coded totally correctly. I hope this helps, though.

Link to comment
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.