Veröffentlicht 7. Mai 201213 j Hallo, also ich habe ein HTML-Formular (Name:myform). In diesem Formular habe ich mehrere Submit-Buttons. Jenachdem welcher Submit-Button gedrückt wurde, möchte ich einen Anker setzen. Die Funktion führe ich beim drücken des Submit-Buttons aus: function setAnker(anker) { t_anker = "index.php?id=243#" + anker; document.myform.action = t_anker; } Wenn ich nun auf einen Button klicke funktioert das alles im Firefox, aber leider nicht nicht im IE. Ich habe schon google gefragt und auch schon verschiedene Möglichkeiten getestet z.B. document.forms.myform.action = t_anker; document.forms[0].action = t_anker; document.forms[0].action.value = t_anker; document.forms.myform.action.value = t_anker; document.getElementById(myform).action.value = t_anker; document.getElementById(myform).action = t_anker; [...] und alles was mir noch so eingefallen ist
17. Mai 201213 j Hi probiers mal so: <script type="text/javascript"> function OnSubmitForm() { if(document.pressed == 'Insert') { document.myform.action ="insert.html"; } else if(document.pressed == 'Update') { document.myform.action ="update.html"; } return true; } </script> <form name="myform" onsubmit="return onsubmitform();"> <input type="submit" name="operation" onclick="document.pressed=this.value" value="insert" /> <input type="submit" name="operation" onclick="document.pressed=this.value" value="update" /> </form>[/PHP] Quelle: How to switch the 'action' field in an HTML form dynamically
Archiv
Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.