homepage Welcome to WebmasterWorld Guest from 50.19.172.0
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
Passing a form variable to action onSubmit?
field4000

10+ Year Member



 
Msg#: 3973904 posted 6:43 am on Aug 18, 2009 (gmt 0)

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.

 

Arno_Adams

10+ Year Member



 
Msg#: 3973904 posted 7:39 am on Aug 18, 2009 (gmt 0)

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

Fotiman

WebmasterWorld Senior Member fotiman us a WebmasterWorld Top Contributor of All Time 5+ Year Member



 
Msg#: 3973904 posted 6:11 pm on Aug 18, 2009 (gmt 0)

Users with JavaScript disabled might not be very happy though.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved