Myth
Myth

Reputation: 446

how to get combobox text in java script from jsp page

I want to pass the test in the combobox to another page as included in query string using JavaScript

<select name="classn" id="classnId" onchange="populate()" > 
<option value="select">--Select--</option>
<option value="1">I Class</option>
<option value="2">II Class</option>
<option value="3">III Class</option>

here is the populate function

function populate(){
            $.ajax({url:"getbatchno.jsp?itid="+$('#classnId').val(),success:function(result){

                }});}

but using the above Script I am able to pass only the value part of combobox and I need to pass the text also(I Class,II Class,... etc).

Upvotes: 0

Views: 2719

Answers (1)

gregjer
gregjer

Reputation: 2843

to get text of selected option with jQuery you could use that:

 $('#classnId option:selected').text();

Upvotes: 1

Related Questions