Login or Sign up Help | Site Map
Connecting Tech Pros Worldwide

onclick and assigning variables?

Question posted by: MrGarcia (Newbie) on September 1st, 2006 03:41 PM
I'm trying to create a link which passes variable data to form objects (text), and also submits the form with the onClick method.

In the head I have..

Code: ( text )
  1. function submitter(one,two){
  2.    document.forms[0].emailaddress.value = one;
  3.    document.forms[0].officername.value = two;
  4.    document.forms[0].submit();
  5.    }

then the link is..
Email:
Code: ( text )
  1. <a href="#" onClick = "submitter('none@none.net', 'Joe Schmoe' ); ">Joe Schmoe</a><br>

the problem is that the string 'Joe Schmoe' is not being submitted, I only get the 'Joe' part. Any clues?
Would you like to answer this question?
Sign up for a free account, or Login (if you're already a member).
acoder's Avatar
acoder
Site Moderator
10,974 Posts
May 12th, 2008
03:05 PM
#2

Re: onclick and assigning variables?
Perhaps it's the server-side where the problem is.

Reply
pronerd's Avatar
pronerd
Expert
303 Posts
May 15th, 2008
03:37 PM
#3

Re: onclick and assigning variables?
It looks like the space is interrupting the data submission which should not happen on any modern browser. Is this submit by change being defined as a GET instead of a POST? If so inserting a space into a GET HTTP request will interrupt it.

If nothing else works you might try encoding the data before sending it. Google can provide examples of how to do this.

Reply
Reply
Not the answer you were looking for? Post your question . . .
183,969 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).

Latest Articles: Read & Comment
Top Javascript / DHTML / Ajax Forum Contributors