views:

21

answers:

3
$("#txt1").whichevent(function(){
    $.post("Serversidefile.php?value="+$("#txt1").attr("value"));   

});

say we are selecting an item from Select box that value comes in to the Text box and i have to Send this text Box value to server side script (PHP ) where i can get the Server side value Any events(Load,focus) any idea

A: 

You are looking for change event:

$("#txt1").change(function(){
    $.post("Serversidefile.php?value="+$("#txt1").attr("value"));   
});

The change event fires when the contents of text box change.

Sarfraz
The Change Event did not work //Here txt1 is the text box which Doesnot contain any value and gets the value on selecting an item from select box $("#txt1").change(function(){alert("event Fired");})
Someone
+1  A: 

why would you want to put the value in a textbox first? .change() is what you need :)

Stefanvds
Please see the comment above
Someone
so wait, how does the textbox get filled? what code is used for that? or does the user input text? change should work... did you put the code in the $(document).ready ... block?
Stefanvds
A: 

You could try the select event:

$("#txt1").select(function() {
    $.post("Serversidefile.php, { value: $(this).val() });   
});

Also notice that the value parameter is sent as the data hash and not concatenated in the url in order to be properly encoded.

Darin Dimitrov
The Select Event did not work //Here txt1 is the text box which Doesnot contain any value when the document loads and gets the value on selecting an item from select box $("#txt1").select(function(){alert("event Fired");})
Someone
@Someone, the select event is triggered whenever you select a text in a textbox with the mouse. Isn't what you were looking for?
Darin Dimitrov
@Darin Dimitrov : No , Here is the problem .i will select a value from autocomplete Say "ABCDXYZ-JKL".On selecting this value So "JKL" would go in to the (#TXT1) So i have to fire the even now $("txt1").whatEvent(function(){ }) . which even need to be fired
Someone