Jump to content

any ideas???


neverett

Recommended Posts

Here's what I'm trying to do.  I have a select list in an HTML form (in a PHP file).  If a person selects 2 for instance, I want a new table row to appear and a textarea to appear in that row.  If a person deselects 2, the new row and textarea should disappear.  I was planning on using onchange, but I'm up for using javascript if that is more efficient.  Also, if the person selects 2, the row and textarea appear, I'd like to automatically put the cursor in the textarea.  Hope that makes sense.  If anyone has any suggestions, I would like to thank you in advance.  Thanks!

Link to comment
Share on other sites

Something like this?

 

<select onclick="document.getElementById('mytextarea').style.display=(this.value)?'':'none';">
  <option value="" selected>--Select an option--</option>
  <option value="option1">Option 1</option>
  <option value="option2">Option 2</option>
  <option value="option3">Option 3</option>
  <option value="option4">Option 4</option>
  <option value="option5">Option 5</option>
</select>
<br>
<textarea id="mytextarea" name="name" style="display:none;"></textarea>

Link to comment
Share on other sites

I can get that to work just fine.  One last question though.  How can I get a similar idea to work only this time to display a table row that contains that textarea?  Basically, if item option2 is selected (clicked), then I want a table row to be displayed that contains that textarea.  Hope that makes sense!  Thanks for all your help!

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.