pjsikora / select-box

Automatically exported from code.google.com/p/select-box
1 stars 0 forks source link

Problem is in chrome, on form submit we are not getting the selected value #12

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
Problem is in chrome, on form submit we are not getting the selected value. 

What is the expected output? What do you see instead?
need to get the value on form select, working fine in mozilla and IE

What version of the product are you using? On what operating system?
jQuery Selectbox plugin 0.2

Please provide any additional information below.
always taking the default value in chrome. on change the value is not changing.

Original issue reported on code.google.com by renjithp...@gmail.com on 28 Mar 2013 at 7:30

GoogleCodeExporter commented 8 years ago
I had the same problem and simply could not fix it... until I got a bit greasy.
Now we are looking at the _changeSelectbox: function here inside the .js file.

Firstly to force the first selected="selected" to remove I added the following:
$(target).find("option").attr("selected", FALSE);

This is fine and should be included from the start. However I found 
specifically in chrome it would not keep that selected (even though in the 
inspector it showed all good). So here's the greasy part:

$("#"+target.id + " option").each(function (elekey, ele) {
    $(ele).val(value);
});

This actually changes the value of every option in the drop down  to be that of 
the option we actually want.

The immediate issue I thought of with this is that it could only be changed 
once, as the selected value would be the same on the second call and would not 
change. However it seems the values are stored elsewhere and it's all working 
sweet on my site.

Goodluck!

Original comment by Jdbd...@gmail.com on 10 Jul 2013 at 2:48

GoogleCodeExporter commented 8 years ago
Hello! 

Also had the problem, fixed it on my own by adding the following lines to the 
function _changeSelectbox before setting the new selected option:

  var actSelected = $(target).find("option[selected='selected']");
  if(actSelected.length > 0) actSelected.attr("selected", FALSE);

Works in Chrome, FF and IE 9. Earlier IE versions are ignored by me :-)

Best regards

Original comment by baumg...@gmail.com on 20 Aug 2013 at 6:08

GoogleCodeExporter commented 8 years ago
Just change prop for attr in $(target).find("option[value='" + value + 
"']").attr("selected", TRUE);

Original comment by tomryche...@gmail.com on 20 Aug 2013 at 9:52