Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

javascript in an HTML form

Status
Not open for further replies.

lisa66

Technical User
May 30, 2006
11
GB
strOutput += "<input type=hidden name=\"M_email\" value=\b_email\>";

i am trying to get my javascript to send particular info through to worldpay. the above is where I have got to but it doesnt work. b_email is my customer email field in the HTML form. When I run the script it simply sends b_email; not the content of the field.

I am very new to this so answers in simple form would be appreciated!! thank you
 
When I run the script it simply sends b_email; not the content of the field.

But "b_email" IS the content of the field:

Code:
strOutput += "<input type=hidden name=\"M_email\" [!]value=\b_email\[/!]>";

If you want something else sent, put other text in.

Hope this helps,
Dan

Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
thanks for the help; don't think I'm explaining this very well - b_email is the name of the text box on my page. I want the email address my customer enter into this box to be posted. I simply get b_email - will the quote marks fix this mbrooks?
 
lisa66, why are you creating the variable strOutput?
How is the value supposed to be passed to worldpay?

If you need the value in the string in strOutput then do this. Add an id tag to your b_email field id="b_email"
Then alter your other line like this:
Code:
strOutput += "<input type=hidden name=\"M_email\" value=\"" + document.getElementById('b_email').value + "\">";
[code]






[COLOR=blue]It's hard to think outside the box when I'm trapped in a cubicle.[/color]
 
thanks for the response niteowl, sorry for my delay in reply. The honest answer to your questions is I don't know. I am trying to copy code I have been given that so far has worked. I thought I could just add a few more fields ... guess not! I have changed my code as you suggested but unfortunately I couldn't get it to work. If I could impose on your time and brain cells a little further; would you look at my checkout page on my site you will see the fields I am trying to collect/post. Below is the extract from my CheckoutBasket()

} else if ( PaymentProcessor == 'wp') {
//Process this for WorldPay
strOutput += "<input type=hidden name=\"instId\" value=\"127858\">";
strOutput += "<input type=hidden name=\"cartId\" value=\"Balloon Moments\">";
strOutput += "<input type=hidden name=\"amount\" value=\""+ moneyFormat((fTotal + fShipping + fTax)) + "\">";
strOutput += "<input type=hidden name=\"currency\" value=\"GBP\">";
strOutput += "<input type=hidden name=\"desc\" value=\""+ strPP + "\">";
strOutput += "<input type=hidden name=\"testMode\" value=\"100\">";
strOutput += "<input type=hidden name=\"M_email\" value=\"" + document.getElementById('b_email').value + "\">";

if you can help me I will be really grateful; if not I am still in awe of you people for your time and generosity. This is the first time I have ever used a forum and I am amazed.
 
Lisa,

You are calling "CheckoutBasket" before the page has loaded. You should wait until AFTER it has loaded (and, in fact, AFTER the user has asked to submit) before calling it, otherwise you will be picking up blank values.

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
thanks Dan - i'm gonna have go at this today. no doubt I will be back but I actually understood your point which give me hope!
 
hello again - i can understand the problem here. I am asking it to collect this data before it has been entered. However I cannot work out how to get this done AFTER the customer has submitted. I have tried running my 'checkoutBasket' after my form has finished but this does not work. Can you help me .... again!
 
If you need to send the email address in a field named "M_email", then simply rename the form field on the page from "b_email" to "M_email" - no extra JavaScript is needed.

Hope this helps,
Dan

Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top