Go Back   CodingForums.com > :: Client side development > JavaScript programming > Ajax and Design

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-11-2009, 11:15 PM   PM User | #16
bigsy85
New Coder

 
Join Date: Dec 2009
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
bigsy85 is an unknown quantity at this point
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>
bigsy85 is offline   Reply With Quote
Old 12-11-2009, 11:30 PM   PM User | #17
hdewantara
Regular Coder

 
hdewantara's Avatar
 
Join Date: Aug 2009
Location: Jakarta, Indonesia.
Posts: 287
Thanks: 4
Thanked 39 Times in 39 Posts
hdewantara is an unknown quantity at this point
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.
hdewantara is offline   Reply With Quote
Old 12-11-2009, 11:32 PM   PM User | #18
bigsy85
New Coder

 
Join Date: Dec 2009
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
bigsy85 is an unknown quantity at this point
Ok thanks, just updated that.

Still doesnt work though.

if you notice when the page is loading it does work?
bigsy85 is offline   Reply With Quote
Old 12-11-2009, 11:34 PM   PM User | #19
hdewantara
Regular Coder

 
hdewantara's Avatar
 
Join Date: Aug 2009
Location: Jakarta, Indonesia.
Posts: 287
Thanks: 4
Thanked 39 Times in 39 Posts
hdewantara is an unknown quantity at this point
OK let me look..
hdewantara is offline   Reply With Quote
Old 12-11-2009, 11:35 PM   PM User | #20
bigsy85
New Coder

 
Join Date: Dec 2009
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
bigsy85 is an unknown quantity at this point
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);
}
}
}
}
bigsy85 is offline   Reply With Quote
Old 12-11-2009, 11:53 PM   PM User | #21
hdewantara
Regular Coder

 
hdewantara's Avatar
 
Join Date: Aug 2009
Location: Jakarta, Indonesia.
Posts: 287
Thanks: 4
Thanked 39 Times in 39 Posts
hdewantara is an unknown quantity at this point
I am confused...
Got this error in FF3.5.3:
Quote:
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]
hdewantara is offline   Reply With Quote
Old 12-12-2009, 12:11 AM   PM User | #22
hdewantara
Regular Coder

 
hdewantara's Avatar
 
Join Date: Aug 2009
Location: Jakarta, Indonesia.
Posts: 287
Thanks: 4
Thanked 39 Times in 39 Posts
hdewantara is an unknown quantity at this point
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?...
hdewantara is offline   Reply With Quote
Old 12-12-2009, 01:01 AM   PM User | #23
hdewantara
Regular Coder

 
hdewantara's Avatar
 
Join Date: Aug 2009
Location: Jakarta, Indonesia.
Posts: 287
Thanks: 4
Thanked 39 Times in 39 Posts
hdewantara is an unknown quantity at this point
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.
hdewantara is offline   Reply With Quote
Old 12-12-2009, 01:20 AM   PM User | #24
bigsy85
New Coder

 
Join Date: Dec 2009
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
bigsy85 is an unknown quantity at this point
Good work, works great!

We finally got there, enjoy your rest.

Thanks.
bigsy85 is offline   Reply With Quote
Old 12-13-2009, 12:46 AM   PM User | #25
hdewantara
Regular Coder

 
hdewantara's Avatar
 
Join Date: Aug 2009
Location: Jakarta, Indonesia.
Posts: 287
Thanks: 4
Thanked 39 Times in 39 Posts
hdewantara is an unknown quantity at this point
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.
hdewantara is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:21 PM.


Advertisement
Log in to turn off these ads.