简体   繁体   中英

form not being submitted on button click php

I've been trying to get my form to submit for two days but no luck. I've gone through my code backwards and forwards. The isset if the statement is not triggering. Its an amateur issue but please help me. I am using js to make the table because it is dependant on DB entries, but for simplicity sake, I have pasted the output HTML. Since I'm using js, I thought it would be easier to give them form tags instead of surrounding each row with a form. I also have the Submit in the same file. I did try to put the different file and like it via action but no cigar. I am using Joomla platform, but I don't think that matters.

Thankyou to anyone who can help me

 <tr> <td>TA Hours <br>Unit: Hours</td> <td><input class="TA Hours input-mini" name="TA HoursMonday" type="number" size="6" min="0" step=".01" form="formTA Hours"></td> <td><input class="TA Hours input-mini" name="TA HoursTuesday" type="number" size="6" min="0" step=".01" form="formTA Hours"></td> <td><input class="TA Hours input-mini" name="TA HoursWednesday" type="number" size="6" min="0" step=".01" form="formTA Hours"></td> <td><input class="TA Hours input-mini" name="TA HoursThursday" type="number" size="6" min="0" step=".01" form="formTA Hours"></td> <td><input class="TA Hours input-mini" name="TA HoursFriday" type="number" size="6" min="0" step=".01" form="formTA Hours"></td> <td><input class="TA Hours input-mini" name="TA HoursSaturday" type="number" size="6" min="0" step=".01" form="formTA Hours"></td> <td><input class="TA Hours input-mini" name="TA HoursSunday" type="number" size="6" min="0" step=".01" form="formTA Hours"></td> <td><input type="submit" value="Save" name="buttonTA Hours" form="formTA Hours"></td> <td> </td> </tr> <form name="formTA Hours" method="post"><input type="text" name="Name" value="TA Hours" form="formTA Hours" style="display: none;"></form>

Heres the PHP trying to make a popup

</script>
<?php
if(isset($_POST['buttonTA Hours'])){
    echo 'alert("isset works")';
}
?>
</script>

Your <tr></tr> has to be inside the <form> . All the values inside the form get submitted in $_POST your input with name "buttonTA Hours" is not inside the form so its not being submitted.

Currently, when you submit the form all you're submitting is <input type="text" name="Name" value="TA Hours" form="formTA Hours" style="display: none;">

Your code should look like this:

<form>
  <tr>
     <td>
     ...
     ...
  </tr>
</form>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM