Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
87
rated 0 times [  93] [ 6]  / answers: 1 / hits: 29544  / 13 Years ago, wed, october 19, 2011, 12:00:00

I want to get the value of the select box using javascript i have the following code.



html part



<select name=marked id=marked onchange=checkdata(this); >
<option value=>SELECT</option>
<option value=all>ALL</option>
<option value=none>NONE</option>
<option value=read>READ</option>
<option value=unread>UNREAD</option>
</select>


script



<script type=text/javascript>
function checkdata()
{
for(var i=0; i < document.myform.message.length; i++)
{
document.myform.message[i].checked=true;
}
}
</script>


i tried the code



var all = document.myform.marked.options[document.myform.selectedIndex].value;
alert(all);


no alert is coming



i also tried



 var all= document.getElementById('marked').value;
alert(all);


alert is coming but the value for every selection in 1


More From » html

 Answers
10

You missed the '.marked':



var all = document.myform.marked.options[document.myform.marked.selectedIndex].value;
alert(all);

[#89539] Monday, October 17, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
harleyterryp

Total Points: 290
Total Questions: 92
Total Answers: 95

Location: Montenegro
Member since Sun, May 7, 2023
1 Year ago
;