Welcome to WebmasterWorld Guest from 107.22.7.35

Forum Moderators: open

Message Too Old, No Replies

Passing a form variable to action onSubmit?

     
6:43 am on Aug 18, 2009 (gmt 0)

10+ Year Member



Hi all,

I am having a bit of trouble trying to solve an issue.

My issue:

- I have a form with an input field.
- I need to pass the value of said input filed into the form's action. That is, I need to generate a URL based on the value of the input field.

So if the user inputs the value "hello", I need the action to be: action="page/hello".

Is this possible?

Any help with this would be much appreciated.

Cheers in advance.

7:39 am on Aug 18, 2009 (gmt 0)

10+ Year Member



Hi, try this:

function s(o) {
o.action = 'page/' + o.elements[1].value;
}

and the form looks like this


<form id="frm" method="post" action="/" onsubmit="s(this);">

HTH, Tom

6:11 pm on Aug 18, 2009 (gmt 0)

WebmasterWorld Senior Member fotiman is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



Users with JavaScript disabled might not be very happy though.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month