| | |
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 ajaxhelp ajaxjspservlets animate automatically beta box browser bug captchaformproblem checkbox close codes createrange() css cursor debugger decimal dependent disablefirebug dom download dropdown editor element engine enter error events explorer ext file firefox form frameworks getselection google gwt gxt hiddenvalue highlightedword hint html htmlform ie7 ie8 iframe index internet java javascript javascripthelp2020 jawascriptruntimeerror jquery jsf jsfile jsp jump listbox maps masterpage math media menu microsoft mp4 object onmouseoutdivproblem paypal pdf php player position programming progressbar prototype redirect regex runtime safari scale scriptlets search security select size software sql text textarea unicode w3c window windowofwords windowsxp wysiwyg \n





