one form two buttons(well three)

P

Poko

Hi all

Was wondering if someone could show me how I can use javascript to submit a
form using three separate buttons that would cause the forms action="" to
hold different values?
Poko
 
M

McKirahan

Poko said:
Hi all

Was wondering if someone could show me how I can use javascript to submit a
form using three separate buttons that would cause the forms action="" to
hold different values?
Poko

Will this help? Watch for word-wrap.

<html>
<head>
<title>3actions.htm</title>
<script type="text/javascript">
function submits(what) {
document.form1.action += "?" + what;
document.form1.submit();
}
</script>
</head>
<body>
<form action="3actions.htm" method="post" name="form1">
<input type="button" value="1" onclick="submits(1)">
<input type="button" value="2" onclick="submits(2)">
<input type="button" value="3" onclick="submits(3)">
</form>
</body>
</html>
 
E

Evertjan.

McKirahan wrote on 24 okt 2005 in comp.lang.javascript:
Will this help? Watch for word-wrap.

<html>
<head>
<title>3actions.htm</title>
<script type="text/javascript">
function submits(what) {
document.form1.action += "?" + what;
document.form1.submit();
}
</script>
</head>
<body>
<form action="3actions.htm" method="post" name="form1">
<input type="button" value="1" onclick="submits(1)">
<input type="button" value="2" onclick="submits(2)">
<input type="button" value="3" onclick="submits(3)">
</form>
</body>
</html>

No javascript needed, use the [default] 'Get' method:

<form action="3actions.htm" method="get">
<input type="submit" value="do1" name="theAction">
<input type="submit" value="do2" name="theAction">
<input type="submit" value="do3" name="theAction">
</form>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top