Sunday, 15 September 2013

Dropdownlist onChange event is never called using javascripts

Dropdownlist onChange event is never called using javascripts

I need a value from my dropdownlist present in my jsp to a servlet class.
The jsp contains
<select name="DropDownList1" onchange="change(this);">
<option value="A">A</option>
<option value="B">B</option>
</select>
<script type="text/javascript">
function change(sel)
{
var url1=sel[sel.selectedIndex].value;
var toServer = myJSONObject.toJSONString();
var request=new XMLHttpRequest();
request.open("POST",
"http://localhost:8080/test/Testing?stringParameter="+stringParameter
, true);
request.send(toServer);
return false;
}
Now the problem is that the onchange event is never called and nothing
happens! What do i do?

No comments:

Post a Comment