| | |
Dynamic ID
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
Hi,
I'm creating the layout for a dynamic webshop, all pictures are getting dynamic IDs to have their elements changed. I'm currently having errors with the code below and have no idea why.
the argument id is not null, however
document.getElementById(id) is. I don't understand how that can happen
This is my javascript code
This is my php code:
EDIT: what's even stranger is that it all works, when I leave out the if, I just have a FireFox Addon which showed me those errors.
Any help would be very well appreciated.
Thanks
I'm creating the layout for a dynamic webshop, all pictures are getting dynamic IDs to have their elements changed. I'm currently having errors with the code below and have no idea why.
the argument id is not null, however
document.getElementById(id) is. I don't understand how that can happen

This is my javascript code
javascript Syntax (Toggle Plain Text)
<script type="text/javascript"> function change_bg(id) { if(id != null && document.getElementById(id) != null) { document.getElementById(id+'bg').src='product_bg_big.png'; document.getElementById(id+'fg').src='product_fg_big.png'; document.getElementById(id).src='product_i_big.png'; } else { confirm(''); } } function change_bg_back(id) { if(id != null && document.getElementById(id) != null) { document.getElementById(id+'bg').src='product_bg.png'; document.getElementById(id+'fg').src='product_fg.png'; document.getElementById(id).src='product_i.png'; } else { confirm(''); } } </script>
This is my php code:
php Syntax (Toggle Plain Text)
echo "<td> <img id='product".$numProduct."fg' src='product_fg.png' alt='product_fg' onmouseover=javascript:change_bg('product".$numProduct."') onmouseout=javascript:change_bg_back('product".$numProduct."')> </td>";
EDIT: what's even stranger is that it all works, when I leave out the if, I just have a FireFox Addon which showed me those errors.
Any help would be very well appreciated.
Thanks
Last edited by brechtjah; Nov 22nd, 2008 at 5:26 pm. Reason: Forgot text
![]() |
Similar Threads
- Dynamic pull out menus (JavaScript / DHTML / AJAX)
- Creating dynamic array structures (C++)
- Dynamic web pages? Which will exist? (IT Professionals' Lounge)
- dynamic IP's and Websites (Domains and DNS)
- Core PHP Programming to Build Dynamic Websites (PHP)
- Dynamic Drive Overlay Win98 80 gig support (Windows 95 / 98 / Me)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Adding Array To Another Array
- Next Thread: calculate mean function!
| Thread Tools | Search this Thread |
acid2 ajax ajaxcode ajaxexample ajaxjspservlets array browser bug calendar captchaformproblem cart checkbox child close codes createrange() cursor date debugger decimal dependent disablefirebug dom dropdown editor element embed engine enter events explorer ext file firefox focus form forms frameworks getselection google gxt hiddenvalue highlightedword hint html ie7 ie8 iframe images index internet java javascript javascripthelp2020 jquery jsf jsfile jsp jump libcurl listbox maps masterpage math media menu mp4 object onmouseoutdivproblem onmouseover onreadystatechange parent paypal pdf php position post programming progressbar prototype redirect regex runtime safari scale scriptlets scroll search security shopping size software sql text textarea unicode web windowsxp wysiwyg \n





