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? Link to comment https://forums.phpfreaks.com/topic/221847-submitting-only-a-particulat-field-whene-there-are-many-fiels-in-a-form/ 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 Link to comment https://forums.phpfreaks.com/topic/221847-submitting-only-a-particulat-field-whene-there-are-many-fiels-in-a-form/#findComment-1148013 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, Link to comment https://forums.phpfreaks.com/topic/221847-submitting-only-a-particulat-field-whene-there-are-many-fiels-in-a-form/#findComment-1148015 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 Link to comment https://forums.phpfreaks.com/topic/221847-submitting-only-a-particulat-field-whene-there-are-many-fiels-in-a-form/#findComment-1148018 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> Link to comment https://forums.phpfreaks.com/topic/221847-submitting-only-a-particulat-field-whene-there-are-many-fiels-in-a-form/#findComment-1148025 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 Link to comment https://forums.phpfreaks.com/topic/221847-submitting-only-a-particulat-field-whene-there-are-many-fiels-in-a-form/#findComment-1148028 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.