bindiya Posted December 16, 2010 Share Posted December 16, 2010 I have a webpage in php which contains many fiields.But when i enter data into one particular field(say the first field),i need the form to get submitted and do certain task.How can i achieve this? Quote Link to comment Share on other sites More sharing options...
solon Posted December 16, 2010 Share Posted December 16, 2010 So you want the complete form to be submited even with empty fields automatically as a user writes in the field or when he changes a field? Either way you need to use javascript to manipulate the data on the client side. document.yourform.submit() or if you want to do server side functions use ajax to send it to php file where you will handle the form data. Now to actually do the abaove you need to call a function either: onkeyup='your_javascript_function()' or onblur='your_javascript_function()' This would have to be like: <input type='text' name='your_field' id='your_field' onblur='your_javascript_function()' /> or <input type='text' name='your_field' id='your_field' onkeyup='your_javascript_function()' /> I hope this helps Quote Link to comment Share on other sites More sharing options...
bindiya Posted December 16, 2010 Author Share Posted December 16, 2010 the problem is in my form i have only one submit button.But before clicking that submmit button i nned a textfield to be submitted when the mouse goes to the second textfield, Quote Link to comment Share on other sites More sharing options...
solon Posted December 16, 2010 Share Posted December 16, 2010 Then on the first text field use the onblur like : <input type='text' name='your_field' id='your_field' onblur='your_javascript_function(this.value)' /> were you see your_javascript_function(this.value) it's the function that will handle the data from that form Quote Link to comment Share on other sites More sharing options...
bindiya Posted December 16, 2010 Author Share Posted December 16, 2010 do i need to code this way <form name='usercheck' method="post" action='useravailability.php'> <input name="username" type="text" id="username" value="" maxlength="15" onblur='submit(this.value);'/></td><td width="185"></form> Quote Link to comment Share on other sites More sharing options...
solon Posted December 16, 2010 Share Posted December 16, 2010 well submit() is a reserved javascript function so its better to use another name for your function. like chk() for check. But yes that is the general idea. Also you need to have a function like <script type="text/javascript"> function chk(username) { //do something here } </script> in order to get the value and handle it the way you want within the function Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.