SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    E-business guru Eirik's Avatar
    Join Date
    Nov 2000
    Location
    Oslo, Norway
    Posts
    413
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Code not working in Firefox

    Hi guys,

    I was wondering if you could be as kind as to take a glance at the code below and tell if if there are any obvious errors as to why the code won't work in Firefox (more specifically, the form fields aren't populated when an option in the drop down box is selected).

    Thanks in advance !

    Code:
    <script language="JavaScript">
    <!--
    function clicked(id) {
    var products = new Array();
    products[0] = new Array('0,00', '', '0,00');
    products[104] = new Array('75', 'Product 1', '25');
    products[105] = new Array('195', 'Product 2', '25');
    document.getElementById("price["+id+"]").value = products[document.getElementById("product["+id+"]").value][0];
    document.getElementById("description["+id+"]").value = products[document.getElementById("product["+id+"]").value][1];
    document.getElementById("vat["+id+"]").value = products[document.getElementById("product["+id+"]").value][2];
    }
    //-->
    </script>
    <form action="" name="children" method="post">
    <select name="product[141]" onChange="clicked(141);return false;">
    <option value="0">Select a product</option>
    <option value="104" >Product 1, kr 75</option>
    <option value="105" >Product 2, kr 195</option>
    </select>
    <input type="text" id="price[141]" name="price[141]" />
    <input type="text" id="vat[141]" name="vat[141]" />
    <textarea id="description[141]" name="description[141]"></textarea>
    </form>
    Sincerely,

    Eirik Johansen
    Netmaking AS

  2. #2
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Portsmouth UK
    Posts
    1,499
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    name and id a very different
    its just that IE is weird

    PHP Code:
    <select name="product[141]" id="product[141]" onChange="clicked(141);return false;"

    id name must be unique

    duplicate names form an array MyName[0], MyName[1] ................

  3. #3
    E-business guru Eirik's Avatar
    Join Date
    Nov 2000
    Location
    Oslo, Norway
    Posts
    413
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks a lot, vwphilips!
    Sincerely,

    Eirik Johansen
    Netmaking AS


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
  •