irkevin Posted August 28, 2009 Share Posted August 28, 2009 Ah the title says, I want to have a link acting as a submit button. I made it. Like below: <script type="text/javascript"> function submitForm(type){ for(i = 0;i < post_form.lenght;i++) document.post_form.post[i].value = type; document.post_form.submit(); } <form method="post" action="test.php" name="post_form"> <input type="checkbox" name="post[]" value="1" /> 1 <input type="checkbox" name="post[]" value="2" /> 2 <input type="checkbox" name="post[]" value="3" /> 3 </form> <a href="javascript:submitForm('delete');">Delete</a> </script> But, when using a submit button, you specify the <name> attribute to use it with php. Like below <input type="submit" name="submit" value="submit" /> The name submit will be use in php. But when using a link, how do I specify a name to refer it to php? Can someone please help? Link to comment https://forums.phpfreaks.com/topic/172254-link-as-submit-button-a-little-problem-bugging-me/ Share on other sites More sharing options...
haku Posted August 28, 2009 Share Posted August 28, 2009 Just check to see if $_POST exists: if(isset($_POST)) { // do your stuff here } But, I'll add that you really shouldn't do this - it's a bad use of javascript. Anyone who has it turned off won't be able to use your form. Link to comment https://forums.phpfreaks.com/topic/172254-link-as-submit-button-a-little-problem-bugging-me/#findComment-908329 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.