Forms buttons

admin

Administrator
Staff member
He everyone,

How can I make to buttons in a form (this ain't the problem) but how can i point these buttons to a page normal you can do this with action in the <form> but now button1 has to go to page2 and button2 to page3

So plz help

Grtz,

BlogedAre button1 and button2 submit buttons or forward buttons? The code should be the same either way; all you should have to do is set the onClick (or onSubmit) to redirect using window.location=[page_address].

Something like the following:
<input type=button value=test onClick=window.location="a.htm">Thats what I needed

Thnx,

Grtz,

BlogedIt didn't work this is the form code please edit it so it will work...


<FORM name="test" method="post">
<TABLE border=0>
</TR><TR>
<TD><INPUT type="submit" name="hosting" value="E-mail/Hosting toevoegen" onClick=window.location="testb.html"></TD>
<TD><INPUT type="submit" name="betalen" value="Naar betalingsscherm" onClick=window.location="testc.html"></TD>
</TR>
</TABLE>

Grtz,

BlogedDid you try onSubmit in place of onClick?Yes I've tried both onClick as onSubmit failed..

Grtz,

BlogedHere, this should work. I tested it and it works on my computer, but you will have to modify your html. The button has to be of type button for the page to redirect. To compensate I have a JavaScript function to redirect the page. In or to tell the function what page to redirect you need to change test.htm to your page URL.

<script language="JavaScript">
function redirect(page)
{
Form.submit();
window.location=page;
}
</script>
<form name="Form" method="post">
<input type="button" value="test" OnClick="redirect('test.htm')">

Your html would look like:
<input type="button" name="hosting" value="E-mail/Hosting toevoegen" onClick="redirect('testb.html')">
<input type="button" name="betalen" value="Naar betalingsscherm" onClick="redirect('testc.html')">Sorry but now when I click a button it popus with the:


Error on page


Hope I translated it right cause my browser is in Dutch...

My browser version is:
5.00.2614.3500

Maybe thats it but I think it's not...

Grtz,

BlogedIs the error message a JavaScript error message (the status symbol turns yellow) or is it that the page won't load. Just to make sure the page value needs the full URL if the page isn't in the same folder. All I know is that the script worked for me so if you could give me as much detail as possible related to the error, that would be helpful.Ok I'll try to translate the error

First the page loads everything is ok, but when I click on a button the error pops up:


Line: 7
Char: 6
Error: 'form' is not declarated Hope I translated this OK
Code: 0
URL: .....


Grtz,

Bloged

P.S. I'm working off-lineExtra not:

The line and char are pointing the f of form...

Grtz,

BlogedMake sure that the "F" in "Form.submit();" and in "form name="Form" method="post"> are the same case when you translate them. (Either both capital or both small letter Fs).I've done that...

Cause I know Unix is cause sensetive so I mind that everytime

Grtz,

BlogedI don't know why the page won't work correctly. I've tried the page with IE 5.0 and it worked. The only possibility that I can think of is that maybe the Unix version of IE is different or else you happened to translate the code wrong.

You can view English pages right? If you want to see a working example of the script I gave you, you can go to: <!-- m --><a class="postlink" href="http://prodeveloping.tripod.com/Temp/test.html">http://prodeveloping.tripod.com/Temp/test.html</a><!-- m -->. I had to take out the method="post" because it is free space but everthing else is the same.I just tried the script as well (offline) copy & pasted it into notepad, created the testb/c.html files, and it worked!

Bloged,

Is this page going to be online sometime? If so, do you have the ability to upload it wherever its going to be so it can be looked at?So someone else agrees with me! Just kidding. I didn't think that it was on my end. Bloged-I think that it has to do with the translation or your Dutch IE or your unix system.Ok i'll test it one more time...

If not working it will be in <!-- m --><a class="postlink" href="http://www.bdreg.nl/test.html">http://www.bdreg.nl/test.html</a><!-- m -->

Grtz,

Bloged

P.S. It's in DutchOk go ahead it's not working....

Ok I know it's looking simple but first I need to get the page running before I can add some fancy stuff...

Grtz,

BlogedI tried to view the page at <!-- m --><a class="postlink" href="http://www.bdreg.nl/test.html">http://www.bdreg.nl/test.html</a><!-- m --> but I couldn't even get it to load--that isn't the main problem is it. Could that be because it is in Dutch? I also tried to view the source via view-source:http://www.bdreg.nl/test.html but got nothing (it is suppose to show the source without loading the page).Sorry my fault the URL is <!-- w --><a class="postlink" href="http://www.bdreg.nl/test/test.html">www.bdreg.nl/test/test.html</a><!-- w -->

Grtz,

BlogedI looked at <!-- w --><a class="postlink" href="http://www.bdreg.nl/test/test.html">www.bdreg.nl/test/test.html</a><!-- w --> and, yes, I do know what is wrong with that page. The form tag reads: <FORM name="test" method="post"> so the JavaScriopt in the redirect function should be test.submit(); not form.submit(). In my example I had <form name="form" method="post">, that's why the JavaScript was form.submit(). Sorry for any confusion/furstration.Sorry to bother you again, but it ain't working now (offline it's working perfect, but online (most important) gives a error). Can you plz take another peek at the source the URL = <!-- m --><a class="postlink" href="http://www.bdreg.nl/test/test.html">http://www.bdreg.nl/test/test.html</a><!-- m -->

Grtz,

BlogedI'm glad you can see I'm not full of hot air. The only problem is that I went back to the page and it worked. What is wrong with it? The page redirected and everything. If the page doesn't work for you can you then supply the error message again?Ok here it is


Method Not Allowed
The requested method POST is not allowed for the URL /test/testb.html.


--------------------------------------------------------------------------------

Apache/1.3.14 Ben-SSL/1.41 Server at <!-- w --><a class="postlink" href="http://www.bdreg.nl">www.bdreg.nl</a><!-- w --> Port 80


Grtz,

BlogedAre you looking at the same site I am? I didn't get that error message when I went to the page. The only other possiblility is that the space that you got from the webhost doesn't allow you to use a method="Post". But again I didn't have any problem with it.

On a side note, are you using any server-side script to gather the information and then e-mailing it to you because currenlty the page doesn't e-mail by itself (the page sends the information to the server, possilbly causing the error). It may work with a mailto: attribute in the form tag, but that's messy.I think were both looking @ <!-- w --><a class="postlink" href="http://www.bdreg.nl/test/test.html..">www.bdreg.nl/test/test.html..</a><!-- w -->.

And my webhost allows everything I want, cause I'm my webhost!

Grtz,

BlogedThe problem could be that there is no action associated with the form;

<FORM name="persgegevens" method="post">

it should be something like:

<FORM name="persgegevens" method="post" action="myscript.xxx">

where xxx is whatever type of scripting language you are using (cgi, pl, PHP, etc.)

you need a server side script to process the form.

Regards,
Kevinhere, even with onClick, you need to tell the form not to do anything.


<FORM>
<input type=submit value="GOTO A.HTML" onClick="window.location='a.html'; return false;">
<input type=submit value="GOTO B.HTML" onClick="window.location='b.html'; return false;">
</FORM>



the "return false;" is what you're missing.
this tells the form not to return.

or, if you wanna put the code in a function, do this:

<input type=submit value="Handled by Function" onClick="return yourFunction();">


now, if yourFunction returns false, the form won't handle the "action=" parameter...if it returns true, it'll use "action="
 
Back
Top