HTML Select returning user-visable text not value field
I am having an issue with a SELECT tag i开发者_C百科n an HTML form on an ASP page. This will have varying numbers of options under it, and is generated dynamically from a database. Code below;
<select name='select1' id='select1' size='10'>
<option value="12345678901234567890">User-Friendly Text 1</option>
...
<option value="10000039373766232452">Text 2</option>
</select>
The issue is that when this form is submitted to the next asp page, the value returned is 'Text 2' for example, or 'User-Friendly Text 1'. Can anyone explain why the text is being submitted and not the value of the select? I need the value more than the text!!
I've narrowed own the issue to this bit of JavaScript
var lb = document.getElementById('fb_friend');
arrTexts = new Array();
for(i=0; i<lb.length; i++) {
arrTexts[i] = lb.options[i].text;
}
arrTexts.sort();
for(i=0; i<lb.length; i++) {
lb.options[i].text = arrTexts[i];
lb.options[i].value = arrTexts[i];
}
The line lb.options[i].value = arrTexts[i];
is causing the issue here.
Well this shines a positive light on my first post... sorry guys. Removed the line of java that was changing the value. I think this is a sign that 16 hours of straight coding is enough now. Sorry!
精彩评论