Page 1 of 2 12 LastLast
Results 1 to 10 of 11
  1. #1
    Join Date
    Sep 2012
    Posts
    254
    Plugin Contributions
    0

    Default Trouble adding some javascript

    I am trying to add google address autocomplete to my site's create account page. I have the javascript code source getting pulled from the jquery_create_account.js file and using page source I can see it loading and have the autocomplete box displayed. However it is not populating anything when I start typing in an address using safari, chrome or firefox. All of the browsers show I am getting an "uncaught Reference error: google is not defined" How would I go about fixing this? At this point I have simply copied the api code into the javascript file and haven't made any changes to populate the correct fields so there are no errors outside of zen-cart. I tried it on another test form I created not the example one provided and it works perfectly so it's just not playing nicely with zen-cart.
    You may see the error at https://onlineorder.sshorepizza.com/...ain_page=login

    The google autocomplete field is is the third one down that says please don't use this section yet. (This isn't a public site.)

    Thank you for your guidance.

  2. #2
    Join Date
    Jul 2012
    Posts
    16,751
    Plugin Contributions
    17

    Default Re: Trouble adding some javascript

    Link didn't "copy" properly...
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  3. #3
    Join Date
    Sep 2012
    Posts
    254
    Plugin Contributions
    0

    Default Re: Trouble adding some javascript

    moved a couple things around now the error is on autocomplete.setBounds view here.

  4. #4
    Join Date
    Jul 2012
    Posts
    16,751
    Plugin Contributions
    17

    Default Re: Trouble adding some javascript

    FYI, reported that there is a certificate error... Don't know if google has made that part of their process and could be an issue, but thought worth mentioning possibly.

    Couple of other things, looks like there are some other errors on the page that could/might affect the javascript from running. There are two instances of <body tags on the page. One at line 633 and the other at 818.

    Got an undefined result when attempting to use the code contained within the if statement.

    Seeing the duplicate body tag, perhaps the onload code should be moved up to where the body tag was first called.

    What is currently line 633:

    Code:
    <body id="loginBody"onload="update_zone(document.create_account); update_zone_shipping(document.create_account);">
    
    To be made to:

    Code:
    <body id="loginBody"onload="update_zone(document.create_account); update_zone_shipping(document.create_account); initialize();">
    
    Might take a smidge to find exactly where to put that, but...
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  5. #5
    Join Date
    Jul 2012
    Posts
    16,751
    Plugin Contributions
    17

    Default Re: Trouble adding some javascript

    Yeah, actually I get it now, looks like your initialize function is never called... Not sure if there is some other javascript error, but probably should move the initialize function ahead of the other onload operations...
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  6. #6
    Join Date
    Sep 2012
    Posts
    254
    Plugin Contributions
    0

    Default Re: Trouble adding some javascript

    thank you. I found it in includes/modules/pages/login/onload_login.js Between your help and Lat9 I have it working and am learning so much on how to do this. Thank you all but especially both of you for your willingness to help me learn!

  7. #7
    Join Date
    Jul 2012
    Posts
    16,751
    Plugin Contributions
    17

    Default Re: Trouble adding some javascript

    Well the tough ones are the fun ones. :)
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  8. #8
    Join Date
    Sep 2012
    Posts
    254
    Plugin Contributions
    0

    Default Re: Trouble adding some javascript

    I have everything working properly except for some reason I cannot place the zipcode or telephone into the respective elements. I am using
    Code:
    document.getElementById('postcode').value = zipcode;
    and
    Code:
    document.getElementById('telephone').value = phone;
    zipcode and phone are variables. I can see the zipcode variable in safari developer's show page resources screen. So it is populating. I have tried making var phone = "test"; to see if it is working. I can put these values in other element id locations such as id="firstname" or id="lastname" but not the id="postcode" or id="telephone".

    Any ideas? here is the page again if you need it.

    Thank you!

  9. #9
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,631
    Plugin Contributions
    88

    Default Re: Trouble adding some javascript

    You've got another HTML error to resolve. The section that looks like:
    Code:
       <fieldset class="fec-company">
        
        <legend>Please enter your address legend</legend>
        	<div id="locationField">
            <label class="inputLabel" for="google_address">Type address here for it to autofill everything but the zip code</label>
            <input id="autocomplete" placeholder="Enter your address" onFocus="geolocate()" type="text" required ></input>
            </div>
         </fieldset>
    has an invalid input statement; the section should be coded as follows, self-closing the <input> tag:
    Code:
        <fieldset class="fec-company">
        
        <legend>Please enter your address legend</legend>
        	<div id="locationField">
            <label class="inputLabel" for="google_address">Type address here for it to autofill everything but the zip code</label>
            <input id="autocomplete" placeholder="Enter your address" onFocus="geolocate()" type="text" required />
            </div>
         </fieldset>

  10. #10
    Join Date
    Sep 2012
    Posts
    254
    Plugin Contributions
    0

    Default Re: Trouble adding some javascript

    That's so funny you mention that because I was doing it the way you mentioned and my teacher last semester kept telling me that was wrong. I kept telling him it's how I see the code written. :)

    Any ideas why I can't access the zip code or phone number elements with the id's of postcode and telephone?

    Thank you

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. javascript based navigation trouble
    By PomND in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 14 Aug 2011, 01:44 PM
  2. Newsletter help / Some javascript
    By visua in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 20 May 2009, 05:16 PM
  3. Adding some javascript code
    By sjohnstone in forum General Questions
    Replies: 3
    Last Post: 26 Mar 2009, 04:36 AM
  4. Where to add some javascript code?
    By snowy2007 in forum General Questions
    Replies: 11
    Last Post: 22 Feb 2009, 03:31 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR