PHP Form multiple buttons

Posted by Ken on Stack Overflow See other posts from Stack Overflow or by Ken
Published on 2012-04-04T17:25:08Z Indexed on 2012/04/04 17:29 UTC
Read the original article Hit count: 184

Filed under:
|
|
|

I have a form with 2 buttons, that depending on which is selected will either be deleted or edited from the database. Those are each individual pages using SQL statements (questionedit and questiondelete). However, when i press a button, nothing happens...Any Ideas

Here is my javascript

<script type="text/javascript">
 function SelectedButton(button)
{
  if(button == 'edit')
{
document.testedit_questionform.action ="testedit_questionedit.php";
}
else
if(button == 'delete')
{
document.testedit_questionform.action ="testedit_questiondelete.php";
}
document.forms[].testedit_questionform.submit();
}
</script>

Here is my form (being echoed from a loop)

<form name=\"testedit_questionform\" action=\"SelectedButton\" method=\"POST\"> 
<span class=\"grid_11 prefix_1\" id=\"\" >
Question:<input type=\"text\" name=\"QuestionText\" style=\"width:588px; margin-left:10px;\" value=\"$row[0]\"/>
<input type=\"button\" value=\"Edit\" name=\"Operation\"onclick=\"submitForm(\'edit\')\" />
<input type=\"button\" value=\"Delete\" name=\"Operation\"onclick=\"submitForm(\'delete\')\" />
<input type=\"hidden\" name=\"QId\" value=\"$row[3]\" /><br />");
</form>

© Stack Overflow or respective owner

Related posts about php

Related posts about JavaScript