Truble Geschrieben 7. Mai 2012 Geschrieben 7. Mai 2012 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
TitusPullo Geschrieben 17. Mai 2012 Geschrieben 17. Mai 2012 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
Empfohlene Beiträge
Erstelle ein Benutzerkonto oder melde Dich an, um zu kommentieren
Du musst ein Benutzerkonto haben, um einen Kommentar verfassen zu können
Benutzerkonto erstellen
Neues Benutzerkonto für unsere Community erstellen. Es ist einfach!
Neues Benutzerkonto erstellenAnmelden
Du hast bereits ein Benutzerkonto? Melde Dich hier an.
Jetzt anmelden