![]() |
| ||
| Problems with form submition Hi there I have a form that I'm trying to submit but it just doesn't want to play nice. The form i have has 2 submit buttons. One processes php code that updates info in a DB and the other deletes the info in the DB. The problem is that I have a popup asking for confirmation on the deleting and when I click ok nothing happens. All I need to know is how to submit my form using javascript so that it processes the PHP code to delete the DB entry. form tag and delete button <form name="formname" id="formname" method="post" action="<?= $_SERVER['PHP_SELF']?>" onSubmit="return checkWholeForm(this);"> confirmation popup <script type="text/javascript"> Code that deletes DB entry if (isset($_POST['formname'])){ |
| ||
| Re: Problems with form submition Hi, you cant have two submit button on one form, do one thing: have two simple button< input type="button" value="delete"......> and have on hidden field in form with name "task".On onclick event of these button call a function where you set the value of task="delete" or whatever you want, after this submit the form using javascript. On server side check the value of task, according to value you take the action( either delete or add or....), one more thing in all cases you'll be having only one php page, where you will perform action according to "task" value. Have a nice time !!! |
| ||
| Re: Problems with form submition DangerDev, My problem is that I don't know javascript very well and haven't been able to find any solutions. Is the section of code for submitting the form correct? document.formname.submit(); P.S. You can have two submit buttons on one form. I've used it successfully on many pages. |
| ||
| Re: Problems with form submition You can actually have 2 submit buttons in a form. Eg. <?phpBut, since both the buttons are submit buttons, onSubmit event will be fired when you click either of the buttons. |
| ||
| Re: Problems with form submition yes it is correct, but when you are submitting how you are making difference at server side(of which button user has clicked), if you have problem in that see my suggested solution.... |
| ||
| Re: Problems with form submition Quote:
Since you are already using the submit button in your form, you can't submit that way (I think). |
| ||
| Re: Problems with form submition DangerDev, you can know which button was pressed by giving each button a unique name. In my example, I have called it submit1 and submit2. |
| ||
| Re: Problems with form submition Quote:
then there is no problem at all, you can check at server side the name of button and on the base of this you can have intended functionality..... |
| ||
| Re: Problems with form submition Exactly ! |
| ||
| Re: Problems with form submition so is there a way i can call the delete submit button with javascript? eg. document.formname.submitButtonName.submit(); |
| All times are GMT -4. The time now is 4:13 pm. |
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC