SoberDude Posted June 8, 2009 Share Posted June 8, 2009 I have an AJAX script which appends the following to a span (well, it's similar): <select id='select_thing' onchange='functionhere();'> <option value='1' selected>1</option> <option value='2'>2</option> </select> Whenever functionhere() is called, it repeats it (appends the above into that span again). If you select two, it will go back to 1, which it's supposed to do (since, when the AJAX is called, it just puts the above code into the innerHTML). However, if I say: alert(select_thing.value); after changing the value to 2, it always says 2, even though the selected value is 1. So, basically, it seems to be caching the selected option or something. Any fix? Thanks Quote Link to comment Share on other sites More sharing options...
Psycho Posted June 8, 2009 Share Posted June 8, 2009 I haven't a clue what you are talking about. As for this... However, if I say: alert(select_thing.value); after changing the value to 2, it always says 2, even though the selected value is 1. What else would you expect the value of the field to be after changing the value to 2? I think you need to provide more info on what the function is doing when it is called. Quote Link to comment Share on other sites More sharing options...
SoberDude Posted June 8, 2009 Author Share Posted June 8, 2009 After selecting 2, the value automatically changes back to 1, essentially. Since 1 is selected, you would expect for the value to be 1. However, it still says two. Quote Link to comment Share on other sites More sharing options...
SoberDude Posted June 8, 2009 Author Share Posted June 8, 2009 Well, apparently, I fixed it, by adding select_thing.value= this.value into the onchange event. Very odd. .-. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.