Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Per Javascript das action-Attribut aus einem HTML Formular übersteuern

Empfohlene Antworten

Veröffentlicht

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 ;)

  • 2 Wochen später...

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.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.