Jump to content

this.value not being recieved in ie8


freelance84

Recommended Posts

The html source:

<select id="a" name="area" class="select1" onchange="getSub1(this.value)" >
      <option selected="selected"></option>
      <option>Art</option>
</select>

 

The JS

/*getting the sub cat1 are area and returning accordingly*/
function getSub1(str){
alert(str)
/*Check if a an area is selected*/
if (str==""){
	wipeAll();
	return;
}
/*xml connection*/
xmlsetup().....
}

 

The above function works in most browsers... except ie8.

 

In ie8 the alert displays nothing when an item is selected...

 

I know i can get it working if i just send 'this' from the function in the html then get the value from withing the js... but does anyone know a reason why this.value isn't sending the value in ie though?

Link to comment
Share on other sites

You're not actually defining the value of each option, just the text. When the data is posted (the form submitted), browsers default to using the text instead of the value. Browsers also do this when retrieving the value with JavaScript, except for it appears IE.

Link to comment
Share on other sites

  • 4 months later...

I know this reply is a little late, but better late than never. This solution, was cross browser and also meant i did not need to double the info in both the value of the option as well as the text:

 

The select menu:

<select id="a" name="area" onchange="getSub1(this)" >
      <option selected="selected"></option>
      <option>random value</option>
</select>

The js to grab the selected option on change:

/*getting the sub1*/
function getSub1(thisSelect){
str =thisSelect.options[thisSelect.selectedIndex].value;
alert('str');
}

 

(also appologies for not replying sooner adam (think i went on holiday to be honest  :) )

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.