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
https://forums.phpfreaks.com/topic/93736-any-ideas/
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
https://forums.phpfreaks.com/topic/93736-any-ideas/#findComment-480378
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
https://forums.phpfreaks.com/topic/93736-any-ideas/#findComment-480958
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.