Enjoy an ad free experience by logging in. Not a member yet?
Register .
12-11-2009, 11:15 PM
PM User |
#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) (+£5.84)</option>
<option value="15">20x16 (inch) (+£12.97)</option>
<option value="1">25x20 (inch) (+£24.65)</option>
<option value="3">30x25 (inch) (+£29.19)</option>
<option value="2">40x30 (inch) (+£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>
12-11-2009, 11:30 PM
PM User |
#17
Regular Coder
Join Date: Aug 2009
Location: Jakarta, Indonesia.
Posts: 287
Thanks: 4
Thanked 39 Times in 39 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.
12-11-2009, 11:32 PM
PM User |
#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?
12-11-2009, 11:34 PM
PM User |
#19
Regular Coder
Join Date: Aug 2009
Location: Jakarta, Indonesia.
Posts: 287
Thanks: 4
Thanked 39 Times in 39 Posts
OK let me look..
12-11-2009, 11:35 PM
PM User |
#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);
}
}
}
}
12-11-2009, 11:53 PM
PM User |
#21
Regular Coder
Join Date: Aug 2009
Location: Jakarta, Indonesia.
Posts: 287
Thanks: 4
Thanked 39 Times in 39 Posts
I am confused...
Got this error in FF3.5.3:
12-12-2009, 12:11 AM
PM User |
#22
Regular Coder
Join Date: Aug 2009
Location: Jakarta, Indonesia.
Posts: 287
Thanks: 4
Thanked 39 Times in 39 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 , 500 , this . value , 5 ), false );
and have to write:
PHP Code:
document . getElementById ( "id[2]" ). addEventListener ( "change" , getattribimage , false );
So how could we pass the arguments?...
12-12-2009, 01:01 AM
PM User |
#23
Regular Coder
Join Date: Aug 2009
Location: Jakarta, Indonesia.
Posts: 287
Thanks: 4
Thanked 39 Times in 39 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 , 500 , this . value , 5 );
}
document . getElementById ( "attrib-x" ). addEventListener ( "change" , afunc , false );
</script>
Phew, bigsy85... let's have a break ok?
I'm quite dizzy now.
12-12-2009, 01:20 AM
PM User |
#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.
12-13-2009, 12:46 AM
PM User |
#25
Regular Coder
Join Date: Aug 2009
Location: Jakarta, Indonesia.
Posts: 287
Thanks: 4
Thanked 39 Times in 39 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.
Jump To Top of Thread
Thread Tools
Rate This Thread
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
All times are GMT +1. The time now is 09:21 PM .
Advertisement
Log in to turn off these ads.