Jump to content

Getting information from a <select> form item.


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>

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.