Jump to content

Getting information from a <select> form item.


jlange

Recommended Posts

Hi all, I'm not the best with JScript, and I've hit a roadblock in one of my projects because of it.

 

I have a <select> with a lot of options, and another form with fields like username, password, first name, last name, etc. I would like those fields to fill with the information relating to whatever is selected in that <select> The data is generated via PHP from a MySQL database, if that serves any use.

 

I look forward to hearing from you! This community is a great example of how the web lets people help one another and all that sappy stuff.

 

PS, go easy on me, JScript to me is somewhat confusing, what with this.that.this(blah).that = this...PHP seems easier to me.

Link to comment
https://forums.phpfreaks.com/topic/59085-getting-information-from-a-form-item/
Share on other sites

getting the value of a select is easy

<!--this.value is passed to the function showValue()-->
<select id="myselect" onchange="showValue(this.value)">
<option value="1">1</option>
<option value="2">1</option>
<option value="3">1</option>
</select>
<script>
function showValue(val){
  //this will alert the value of the selected option
  alert(val);
}
</script>

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.