kendallkamikaze Posted March 21, 2009 Share Posted March 21, 2009 So when i add this functional javascript form button <div style='width:400px;'> <b>WARNING: READ BEFORE YOU CLICK!</B> Only use this button if you want to delete a horse. It will only euthanize horses over the age of 24. Horses with no children will be completely deleted, horses with children will be considered 'dead' but will appear on the retirement page so that it will not affect the foals pedigree. Dead horses on retirement pages will have a little tombstone appear next to their name and you will no longer be able to change their name, picture or horse log, Therefore you want to make sure that you do ultimately want to euthanize this horse. <script type='text/javascript'> <!-- function confirmation() { var answer = confirm('Are you sure you want to euthanize this horse?') if (answer){ alert('This horse has been euthanized.') window.location = 'horse_euth.php?id=<?PHP echo $_GET[id]; ?>'; } else{ alert('I am sure the horse is happy that you didn't kill him/her!') } } //--> </script> <form> <input type='button' onclick='confirmation()' value='Euthanize'> </form> </div> to this portion of php: <?php $horseid=$_GET['id']; $sql="SELECT * FROM horsedata WHERE id='$horseid' and Owner='$id' and brand='none'"; $result=mysql_query($sql); while($r=mysql_fetch_array($result)) { $horseid=$r["id"]; $horseid2=$r["id"]; $Name=$r["Name"]; $brand=$r["brand"]; echo " <BR><BR><font color='red'> You can only brand your horse once and you are limited to 10 letters/symbols! </font><form name='brand' action='horse_upbrand.php' method='post'> <input type='text' name='brand' MAXLENGTH='10' value='$brand'> <input type='hidden' name='id' value='$horseid2'> <input type='submit' value='Brand your horse!'> </form> FYI: If you want to sell your horse in the future, branding it could make the value of the horse less! <br><br> "; } ?> the button is still there but when you click on it...nothing happens....any ideas? Link to comment https://forums.phpfreaks.com/topic/150420-solved-form-button-in-php-not-working/ Share on other sites More sharing options...
bluejay002 Posted March 21, 2009 Share Posted March 21, 2009 Are you trying to say that the PHP code doesn't work when you clicked the button? If so, The type='button' does not cause the form to submit so it will only work up to the javascript you specified. [EDIT] oh... it was on javascript so button type should work. ^^ Also, I suggest you do add some semicolon thing right after every javascript statement, much cleaner to look at. Link to comment https://forums.phpfreaks.com/topic/150420-solved-form-button-in-php-not-working/#findComment-789999 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.