ksmatthews Posted September 27, 2007 Share Posted September 27, 2007 Hi There, I have the following code which tries to call a php script from a button click .. <a href="delete.php"><input type = "button" value = "Delete" /></a> It does not work ... WHY ? Any ideas ? regards, Steven M Quote Link to comment https://forums.phpfreaks.com/topic/70875-solved-hyperlinking-to-buttons/ Share on other sites More sharing options...
HuggieBear Posted September 27, 2007 Share Posted September 27, 2007 Place the button inside a form and have the form action set to the php script... <form name="myForm" action="delete.php" method="POST"> <input type="button" name="delete" value="Delete"> </form> Regards Huggie Quote Link to comment https://forums.phpfreaks.com/topic/70875-solved-hyperlinking-to-buttons/#findComment-356284 Share on other sites More sharing options...
hemlata Posted September 27, 2007 Share Posted September 27, 2007 Hello, First of all, you made the button to act as a link and in code you are missing with a closing of anchor tag ie </ a>. Other then this the script should work and should take you to 'delete.php'. If it is not taking then explain what exact error you are getting for the same. Regards Quote Link to comment https://forums.phpfreaks.com/topic/70875-solved-hyperlinking-to-buttons/#findComment-356286 Share on other sites More sharing options...
marcus Posted September 27, 2007 Share Posted September 27, 2007 Actually typing </a> will produce [/url] Quote Link to comment https://forums.phpfreaks.com/topic/70875-solved-hyperlinking-to-buttons/#findComment-356293 Share on other sites More sharing options...
ksmatthews Posted September 27, 2007 Author Share Posted September 27, 2007 Thanks Huggiebear, Unfortunately that does not work, even if the type = sumbit instead of button. THe problem is that my button is already within a form (so we have a form within a form) and clicking it will call the parent form action, Steven M Quote Link to comment https://forums.phpfreaks.com/topic/70875-solved-hyperlinking-to-buttons/#findComment-356305 Share on other sites More sharing options...
HuggieBear Posted September 27, 2007 Share Posted September 27, 2007 Oh I see. Why not just create an image and use that as a hyperlink? Huggie Quote Link to comment https://forums.phpfreaks.com/topic/70875-solved-hyperlinking-to-buttons/#findComment-356308 Share on other sites More sharing options...
HuggieBear Posted September 27, 2007 Share Posted September 27, 2007 Alternatively just drop an onClick event in <button name="delete" value="delete" onClick="location.href='http://www.google.co.uk'">Delete</button> Regards Huggie Quote Link to comment https://forums.phpfreaks.com/topic/70875-solved-hyperlinking-to-buttons/#findComment-356309 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.