Click to See Complete Forum and Search --> : [RESOLVED] How do I make assign a button an ordinary link?


OM2
07-25-2008, 07:26 PM
I want to use a button from a form and assign it a link.
How do I do this?
(I actually want to assign it javascript(-1)).

Thanks.


OM

datapunk79
07-25-2008, 10:59 PM
I'm not sure what you're asking for but...

You can assign a action to a form to have it do something or go somewhere depending on what you want the form to do.

If you want to put a link on it then you can assign the form action to that link url. (But you may want to rethink this idea because its a lot of coding that you don't really need.)

<form id="name-of-your-form" action="http://your-first-link-url" method="post">
<input type="submit" value="Your Button Name">
</form>


You said you want to link it to javascript. I don't know that that means but..
You can assign javascript to do something during certain occasions. Like when the button is clicked, or the form is submitted, or the text in a field has changed.

OM2
07-26-2008, 05:11 AM
thanks for the reply.
i was trying to say, i want the link to be "javascript:history.go(-1)"

question: can i have a form inside a form?

thanks.

Centauri
07-26-2008, 07:55 AM
You mean something like :<input name="Back" type="button" value="Go Back" onClick="javascript:history.go(-1)">

OM2
07-26-2008, 07:59 AM
You mean something like :<input name="Back" type="button" value="Go Back" onClick="javascript:history.go(-1)">

exactly what i wanted. :)
thanks.

datapunk79
07-26-2008, 03:08 PM
question: can i have a form inside a form?

Yes, no and maybe. It's possible in HTML, not in XHTML. But you could probably write a PHP or server side script to determine which submit button was clicked. All in all, I would avoid nesting forms if possible.

OM2
07-26-2008, 03:11 PM
Yes, no and maybe. It's possible in HTML, not in XHTML. But you could probably write a PHP or server side script to determine which submit button was clicked. All in all, I would avoid nesting forms if possible.
thanks for the reply.
i would have done this otherwise!

datapunk79
07-26-2008, 03:13 PM
Great, please mark thread as resolved if you don't have any else further.

ray326
07-26-2008, 03:15 PM
Actually forms cannot contain other forms.

datapunk79
07-26-2008, 03:59 PM
Actually forms cannot contain other forms.

Check this out. (http://basic70tech.wordpress.com/2007/05/26/rails-fix-for-nested-forms/)

ray326
07-27-2008, 11:54 PM
From the article:When the new form was created, the HTML validator became a bit upset about the fact that a new form was created within an existing form. This isn’t allowed.