SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    SitePoint Zealot gloryzone's Avatar
    Join Date
    May 2001
    Location
    Indiana
    Posts
    166
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    My javascript is not working in OSX

    Hi all,

    http://www.xplicitonline.com/gil/select_entity.php

    I am trying to get this javascript to work in OSX. It works fine on Windows machines, but when it comes to someone pulling it up on an Apple machine, nothing (whether its Safari or IE).

    Could anyone offer any advice here?
    looking for an Independent Sales Rep...NeedARep
    Michiana's Premier Online Destination- MichianaOnline
    Michiana's Premier Auction Site- AuctionMichiana

  2. #2
    SitePoint Zealot cmorbutts's Avatar
    Join Date
    Apr 2002
    Location
    Sydney, Australia
    Posts
    173
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm not too sure about Safari, but try this. I notice you give your form elements a name like
    <input type="text" name="firstName" />

    What you should do is to add another attribute called id.
    <input type="text" name="firstName" id="firstName" />

    And in your javascript, refer to the element by
    document.getElementById("firstName").value

    That should do it. What's the difference between name and id? If you wanna find out let me know and I'll post a reply (too lazy to type it out now!).

    Let me know if that works for you.

  3. #3
    SitePoint Zealot gloryzone's Avatar
    Join Date
    May 2001
    Location
    Indiana
    Posts
    166
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Jason, do you think this is attributed to why it would work in Windows and not in a Mac machine?
    looking for an Independent Sales Rep...NeedARep
    Michiana's Premier Online Destination- MichianaOnline
    Michiana's Premier Auction Site- AuctionMichiana

  4. #4
    SitePoint Zealot gloryzone's Avatar
    Join Date
    May 2001
    Location
    Indiana
    Posts
    166
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can anyone help me with this problem? Please?
    looking for an Independent Sales Rep...NeedARep
    Michiana's Premier Online Destination- MichianaOnline
    Michiana's Premier Auction Site- AuctionMichiana

  5. #5
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can't see your original source (you changed it); but this:
    Code:
    document.myform.getElementById(package).length;i++)
    ...is incorrect. It's document.getElementById() and it's not used in an object hierarchy, but as an ordinary method of document, returning the object for a (uniquely) id'd element:

    Code:
    for (var i=0; i < document.getElementById('package').length;i++) {
    			if (document.getElementById(package)[i].checked)
    'Nother prob:

    package

    Java word; definately reserved in JavaScript. Lose it immediately, and try again. if still broken, post the url.
    Last edited by adios; Oct 27, 2003 at 22:10.
    ::: certified wild guess :::

  6. #6
    SitePoint Zealot cmorbutts's Avatar
    Join Date
    Apr 2002
    Location
    Sydney, Australia
    Posts
    173
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You should also refer to it as
    document.getElementById("fmFirstName")

  7. #7
    SitePoint Zealot gloryzone's Avatar
    Join Date
    May 2001
    Location
    Indiana
    Posts
    166
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Adios, I tried your suggestion and now its not even working on PC...what could I be doing wrong?
    looking for an Independent Sales Rep...NeedARep
    Michiana's Premier Online Destination- MichianaOnline
    Michiana's Premier Auction Site- AuctionMichiana

  8. #8
    SitePoint Zealot cmorbutts's Avatar
    Join Date
    Apr 2002
    Location
    Sydney, Australia
    Posts
    173
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Gloryzone... post your code online so I can have a look to see what's wrong.

    Basically, you should do this...
    document.getElementById("fmFirstName").value or document.getElementById("fmFirstName").length

    and so on and so on...

  9. #9
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Gloryzone... post your code online so we can all have a look to see what's wrong.
    ::: certified wild guess :::

  10. #10
    SitePoint Guru bronze trophy blufive's Avatar
    Join Date
    Mar 2002
    Location
    Manchester, UK
    Posts
    853
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    From the code:
    Code:
    if(state==""){}else{
    	var package=0;
    As adios pointed out above, "package" is a reserved word in javascript. You can't name a variable "package", or "for", "if" or any other word that's part of the language. Here's a full list of reserved words.

    As a result of those variables, many browsers will be discarding the entire javascript functions/code blocks containing them. That wipes out an awful lot of your code.

    Quote Originally Posted by gloryzone
    why it would work in Windows and not in a Mac machine
    IE/Mac is a completely different beastie from IE/Windows. It almost certainly has differences in the Javascript parser and/or engine. the problem is not confined to Mac - my Mozilla Firebird on Windows is screaming loudly about the bad variable names and dumping whole blocks of code too.

    IE/windows is very forgiving. Sometimes, you can make a colossal mistake and IE/win will just gloss over it, without telling you. You page is broken, but IE managed to figure it out somehow, and won't reveal that there's a problem. Other browsers (including IE/Mac) go down in flames. This could be one of those cases.

  11. #11
    SitePoint Zealot gloryzone's Avatar
    Join Date
    May 2001
    Location
    Indiana
    Posts
    166
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    blufive, thank you for that detailed explanation.

    I was wondering if you could PLEASE help me out by examining the code that I have there now and see if you could modify the code on there for me so that I can get it working. I am not a programmer, I simply own the website that it is to be used on. Four people told me they could help me with the problem and lo and behold, it is still happening. I could email you the page also, if you wish. Thank you again for the detailed answer to my question.

    gil
    looking for an Independent Sales Rep...NeedARep
    Michiana's Premier Online Destination- MichianaOnline
    Michiana's Premier Auction Site- AuctionMichiana


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
  •