0

Hi,

I know for calling jquery function requires some event. But in my project I want to call function of jquery onchange event but that value changing through coding and whenever that value changed jquery function should be called.


That means upto particular condition value will be changed of textbox and uptill function of jquery should be called.

Thanks in advance.

3
Contributors
8
Replies
10
Views
6 Years
Discussion Span
Last Post by twiss
0
<html><head><script>
		
		$(document).ready(function(){

			$("#callPegingId").ajaxError(function(e,xhr,opt){
				alert("Error requesting "+opt.url + ": "+xhr.status+" "+xhr.statusText+" :e = "+e+" "+xhr.responseText);
			})

			$("#callPegingId").change(function(){
					alert("testing hdButtonId.....");
				$.ajax({

					type: "POST",
					data: "sqlQry="+<%=qrySnd%>+"&recSearch="+$(this).val(),
					url: "birthSearchPegination.jsp",
					success: function(result){
						$("#hdButtonId").html(result);
					}
				})
			})
		})

	</script>
</head>
<form>
<input type="hidden" name="callPeging" id="callPegingId" value="check">
<%
// Here is if resultset contain some data then script will be executed

if(rs.next()){%>
											<script>
											    document.getElementById("callPegingId").value = 1;
										
											</script>
									   <%}%>
</form></html>

in the above application if textbox value change to 1 by satisfying if condition and then ajax code should be call.

0

I think the change event will only fire when there is user interaction (user types into a textbox, selects something in a dropdown...). I think what you want is the following:

function callAjax(value){
	$.ajax({
		type: "POST",
		data: "sqlQry="+<%=qrySnd%>+"&recSearch="+value,
		url: "birthSearchPegination.jsp",
		success: function(result){
			$("#hdButtonId").html(result);
		}
	})
}

...

if(rs.next()){%>
											<script>
											    
callAjax(1);
 
											</script>
									   <%}%>
0

Thanx for reply,

if try to call callAjax method in jsp in if condition then it show error like -
The method callAjax(int) is undefined

please help me

0

if I try ur above given solution then it shows me error is "object required" at where we have called callAjax(1) in if condition.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.