<script type='text/javascript'>//<![CDATA[
$(window).load(function(){
$(document).ready(function() {
$("input[name='search_user_submit']").click(function() {
var cv = $('#newInput').val();
var cvtwo = $('input[name="search_option"]:checked').val();
var data = { "cv" : cv, "cvtwo" : cvtwo }; // sending two variables
$("#SR").html('<img src="loading.gif"/>').show();
var url = "user.php";
$.post(url, data, function(data) {
$("#SR").html(data).show();
});
});
});
});//]]>
</script>
This works fine when i hit the button, but when i press enter key all the variables and its values get shown in the address bar.
So how can i add a keypress event for this purpose:-
I have tried this code for keypress still its not working:-
<script type="text/javascript">
$(window).load(function(){
$(document).ready(function() {
function Script(e) {
if (e.keyCode == 13) {
var cv = $('#newInput').val();
var cvtwo = $('input[name="search_option"]:checked').val();
var data = { "cv" : cv, "cvtwo" : cvtwo }; // sending two variables
$("#SR").html('<img src="loading.gif"/>').show();
var url = "user.php";
$.post(url, data, function(data) {
$("#SR").html(data).show();
});
}
}
});
});
</script>
Also for the keypress i am creating the textbox on a click of option button and in my javascript i have specified this:-
input.onkeypress = 'return Script(event)';
return falsefrom your event handler