Jquery assign value to JSP variable -
i new jquery , using jquery populate values in drop down field.
upon selection of value drop down, assigning value hidden field.
onselect: function(index,row){ var val = row.value; alert('val '+val ); $("#hid").val(val ); }
how can assign value jsp variable or if use request.getparameter("hid");
need submit form again value?
edit 1
$(function(){ $('#comb').combogrid({ panelwidth:200, url: 'myservice', idfield:'id', textfield:'desc' columns: [[ {field:'id',title:'id',width:20}, {field:'desc',title:'desc',width:80} ]], onselect: function(index,row){ var val = row.value; alert('val '+val ); $("#hid").val(val ); } });
});
jsp java code runs on server side.
javascript runs on browser.
so cannot assign jsp variables using javascript.
form submit or ajax right choice situation.
ajax code snippet.
onselect: function(index, row) { $.ajax({ url: '/your-url', // path url gets ajax request method: 'get', // or http method want use data: { value: row.value }, success: function(response) { alert('boom!' + response); } }); }
see jquery ajax api docs more information. there lots of options.
Comments
Post a Comment