Pelican Parts
Parts Catalog Accessories Catalog How To Articles Tech Forums
Call Pelican Parts at 888-280-7799
Shopping Cart Cart | Project List | Order Status | Help



Go Back   Pelican Parts Forums > Miscellaneous and Off Topic Forums > Off Topic Discussions


Reply
 
LinkBack Thread Tools Rate Thread
Author
Thread Post New Thread    Reply
Super Moderator
 
cstreit's Avatar
 
Join Date: Feb 2000
Location: Naperville, IL USA
Posts: 14,965
Garage
Javascript guru? Need what I think is easy help

Trying to run this script on a web page that sends some information to a Google API. The pertinent part is this: (removed script tags so it will post)

Quote:

var email_addr = document.getElementById("EditBTAddres").elements["email_field"];
document.write (email_addr);
window.renderOptIn = function() {
window.gapi.load('surveyoptin', function() {
window.gapi.surveyoptin.render(
{
"merchant_id": 1234567,
"order_id": "Order ID",
"email": return email_addr,
"delivery_country": "US",
"estimated_delivery_date": "",
"opt_in_style": "OPT_IN_STYLE"
});
});
}
My problem is - the email address is not getting sent. Instead it is sending "return email_addr" in the section hightlighted in red. Any ideas

__________________
Chris
----------------------------------------------

1996 993 RS Replica
2023 KTM 890 Adventure R
1971 Norton 750 Commando
Alcon Brake Kits

Last edited by cstreit; 11-28-2017 at 12:58 PM..
Old 11-28-2017, 12:56 PM
  Pelican Parts Catalog | Tech Articles | Promos & Specials    Reply With Quote #1 (permalink)
The Unsettler
 
stomachmonkey's Avatar
 
Join Date: Dec 2002
Location: Lantanna TX
Posts: 23,885
Send a message via AIM to stomachmonkey
"email": return email_addr,

"email": "return email_addr",

enclose return email_address in ""

Also, check the form they are filling in, is the field name / value return email_address or return_email_address

Note inconsistent use of underscore between return and email

EDIT: on a side note, try to be more consistent in your use of underscores and capitalization structure. You've got like 3 different styles for the same element. Pick a style you are comfortable with and stick to it, religously. Makes like a lot easier.
__________________
"I want my two dollars"
"Goodbye and thanks for the fish"
"Proud Member and Supporter of the YWL"
"Brandon Won"

Last edited by stomachmonkey; 11-28-2017 at 01:42 PM..
Old 11-28-2017, 01:24 PM
  Pelican Parts Catalog | Tech Articles | Promos & Specials    Reply With Quote #2 (permalink)
Super Moderator
 
cstreit's Avatar
 
Join Date: Feb 2000
Location: Naperville, IL USA
Posts: 14,965
Garage
Quote:
Originally Posted by stomachmonkey View Post
"email": return email_addr,

"email": "return email_addr",

enclose return email_address in ""

Also, check the form they are filling in, is the field name / value return email_address or return_email_address

Note inconsistent use of underscore between return and email

EDIT: on a side note, try to be more consistent in your use of underscores and capitalization structure. You've got like 3 different styles for the same element. Pick a style you are comfortable with and stick to it, religously. Makes like a lot easier.
Thanks. I'm just stealing bits of code. Most of that is Google's API standard code. I only added the first two lines.

So what I added was: var email_addr = document.getElementById("EditBTAddres").elements["email_field"]; because my form is named "EditBTAddres" (yes with the typo) and the field ID is email_field.

I'll try your suggestion. Thanks!
__________________
Chris
----------------------------------------------

1996 993 RS Replica
2023 KTM 890 Adventure R
1971 Norton 750 Commando
Alcon Brake Kits
Old 11-28-2017, 05:18 PM
  Pelican Parts Catalog | Tech Articles | Promos & Specials    Reply With Quote #3 (permalink)
Slackerous Maximus
 
HardDrive's Avatar
 
Join Date: Apr 2005
Location: Columbus, OH
Posts: 18,165
Oh how I hate javascript.

Dunno. I use the inspector in Chrome, throw in a bunch of debugging statements and step through to see whats happening. Not very helpful, I know.
__________________
2022 Royal Enfield Interceptor.
2012 Harley Davidson Road King
2014 Triumph Bonneville T100.
2014 Cayman S, PDK.
Mercedes E350 family truckster.
Old 11-28-2017, 05:48 PM
  Pelican Parts Catalog | Tech Articles | Promos & Specials    Reply With Quote #4 (permalink)
The Unsettler
 
stomachmonkey's Avatar
 
Join Date: Dec 2002
Location: Lantanna TX
Posts: 23,885
Send a message via AIM to stomachmonkey
Quote:
Originally Posted by cstreit View Post
Thanks. I'm just stealing bits of code.
That's what I suspected.

Actually it looks like your issue is what I said before plus the return.

Do this

"email": "email_addr",

You want that because you are looking for what the form is writing to the array.

__________________
"I want my two dollars"
"Goodbye and thanks for the fish"
"Proud Member and Supporter of the YWL"
"Brandon Won"
Old 11-28-2017, 06:42 PM
  Pelican Parts Catalog | Tech Articles | Promos & Specials    Reply With Quote #5 (permalink)
Reply


 


All times are GMT -8. The time now is 04:58 PM.


 
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0
Copyright 2025 Pelican Parts, LLC - Posts may be archived for display on the Pelican Parts Website -    DMCA Registered Agent Contact Page
 

DTO Garage Plus vBulletin Plugins by Drive Thru Online, Inc.