Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HTML Novice - Two buttons on a form

Status
Not open for further replies.

DanAuber

IS-IT--Management
Apr 28, 2000
255
FR
I'm pretty new to HTML but getting there slowly. I want a form where users fill in a couple of boxes and can then choose one of three buttons. Each button will take them to a different new html page posting their input through.

I know I probably need two times
<input TYPE=&quot;text&quot; for the boxes to fill in

and three

<input TYPE=&quot;submit&quot; for the buttons

Then also probably a line

<form ACTION

How do I fill in these lines properly so that what I have described at the top works.

If someone can help me or point me to a page with similar code on it I'd be very gratefull

Dan

Dan Auber
DanAuber@aol.com
 
Well to get the stuff in the textfield:

document.formName.textName.value

and to trigger a function, in each button calla function like so:

<input type=&quot;button&quot; onClick=&quot;redirector()&quot;..>


Now if you want to send data to the new page ypu will have to pack up a query string. (unless you pop up a new window and write it directly)

So in the function redirector:
You will have to create a link, with the query string, and then call it's click method, to activate it. You can hide the link if you wish.

You could modify an existing invisible link, or write an entirely new one to a layer, your choice. Probably easiest simply to modify the href of an existing link.

So this is what the function will do:

- collect text.
- see which button clicked.
- make a string out of both, in the URL?query form.
- write both into the href:

document.all['linkName/ID'].href=&quot;URL?textquery&quot;
- call the link's click() method.



&quot;Alright whatever man, I'll hook up the hair, but I aint touchin the ring...Cause I'm still a pla--yer&quot;
 
or you could just change the action of your form depending upon the button.

<script>
function submitData(str)
{
document.formname.action = str;
document.formaname.submit()
}
</script>

then have your butoons:

<input type=&quot;button&quot; onclick=&quot;submitData('
and that should work. adam@aauser.com
 
And you can probably add aquery to the document.location URL, I'd say.

-Ben. &quot;Alright whatever man, I'll hook up the hair, but I aint touchin the ring...Cause I'm still a pla--yer&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top