Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 2 of 2 FirstFirst 12
Results 16 to 25 of 25
  1. #16
    New Coder
    Join Date
    Dec 2009
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Updated the code again, its still alerting 'HTTP Status: 404 Not Found'

    <label class="attribsSelect" for="attrib-2">1. Canvas Size</label></h4>
    <div class="back">
    <select name="id[2]" id="attrib-2" onchange="getattribimage('id[2]',547,500, this.value,2);">
    <option value="16" selected="selected">-- Please Choose --</option>
    <option value="17">8x10 (inch)</option>
    <option value="18">12x16 (inch) (+&pound;5.84)</option>
    <option value="15">20x16 (inch) (+&pound;12.97)</option>
    <option value="1">25x20 (inch) (+&pound;24.65)</option>
    <option value="3">30x25 (inch) (+&pound;29.19)</option>
    <option value="2">40x30 (inch) (+&pound;42.16)</option>
    </select>

    </div>
    <br class="clearBoth" />
    </div>


    <script type="text/javascript">
    document.getElementById("id[2]").addEventListener("change",getattribimage("id[2]",547,500, this.value,5),false);
    </script>

  2. #17
    Regular Coder hdewantara's Avatar
    Join Date
    Aug 2009
    Location
    Jakarta, Indonesia.
    Posts
    412
    Thanks
    10
    Thanked 61 Times in 60 Posts
    My mistake bigsy85.. I have mistyped it within the latest post.

    Since the HTML tag <select> has id="attrib-xxx" then getElementById should be written as document.getElementById("attrib-xxx").addEventListener(...

    Sorry.

  3. #18
    New Coder
    Join Date
    Dec 2009
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ok thanks, just updated that.

    Still doesnt work though.

    if you notice when the page is loading it does work?

  4. #19
    Regular Coder hdewantara's Avatar
    Join Date
    Aug 2009
    Location
    Jakarta, Indonesia.
    Posts
    412
    Thanks
    10
    Thanked 61 Times in 60 Posts
    OK let me look..

  5. #20
    New Coder
    Join Date
    Dec 2009
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I've added an alert for product_color_image which should have the response text but it is undefined.

    function stateChanged(){
    if (xmlHttp.readyState==4){
    if (xmlHttp.status==200){
    window.alert(product_color_image);
    var
    product_color_image=xmlHttp.responseText;
    window.alert(product_color_image);
    if(product_color_image!=''){
    document.getElementById('productMainImage').innerHTML = product_color_image;

    }
    }
    else{
    with (xmlHttp){
    window.alert("HTTP Status="+status+":"+statusText);
    }
    }
    }
    }

  6. #21
    Regular Coder hdewantara's Avatar
    Join Date
    Aug 2009
    Location
    Jakarta, Indonesia.
    Posts
    412
    Thanks
    10
    Thanked 61 Times in 60 Posts
    I am confused...
    Got this error in FF3.5.3:
    Error: uncaught exception: [Exception... "Could not convert JavaScript argument" nsresult: "0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS)" location: "JS frame :: http://www.icanmakeyouart.co.uk/cust...n-art-portrait :: <TOP_LEVEL> :: line 599" data: no]

  7. #22
    Regular Coder hdewantara's Avatar
    Join Date
    Aug 2009
    Location
    Jakarta, Indonesia.
    Posts
    412
    Thanks
    10
    Thanked 61 Times in 60 Posts
    Ahh I think I know why this error showed up. We could not pass function arguments as in
    PHP Code:
    document.getElementById("id[2]").addEventListener("change",getattribimage("id[2]",547,500this.value,5),false); 
    and have to write:
    PHP Code:
    document.getElementById("id[2]").addEventListener("change",getattribimage,false); 
    So how could we pass the arguments?...

  8. #23
    Regular Coder hdewantara's Avatar
    Join Date
    Aug 2009
    Location
    Jakarta, Indonesia.
    Posts
    412
    Thanks
    10
    Thanked 61 Times in 60 Posts
    Ok. I found an archive related to this @ http://www.codingforums.com/archive/...hp/t-5909.html and did a little experiment.

    Based on that, lets try new script as follows:

    PHP Code:
    <div class="back">
    <
    select name="id[x]" id="attrib-x">
      <
    option...
      ...
    </
    select>
    </
    div>
    <
    script type="text/javascript">
    function 
    afunc(){
      
    getattribimage('id[x]',547,500this.value,5);
    }
    document.getElementById("attrib-x").addEventListener("change",afunc,false);
    </script> 
    Phew, bigsy85... let's have a break ok?
    I'm quite dizzy now.

  9. #24
    New Coder
    Join Date
    Dec 2009
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Good work, works great!

    We finally got there, enjoy your rest.

    Thanks.

  10. #25
    Regular Coder hdewantara's Avatar
    Join Date
    Aug 2009
    Location
    Jakarta, Indonesia.
    Posts
    412
    Thanks
    10
    Thanked 61 Times in 60 Posts
    Congratulation,
    I'm happy too

    Few last notes in using addEventListener():
    a) For usage cleaning reason: should add something like <body unload="removeEventListener("change",afunc,false);"> within each of your HTML pages.
    b) For cross browser compability sake: IE uses other its own method w/ same functionality (I forgot what it is).

    Nice working with you.


 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •