| | |
Specifying the bg & hover images of a div using the value supplied in a text box
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jan 2009
Posts: 33
Reputation:
Solved Threads: 0
Specifying the bg & hover images of a div using the value supplied in a text box
0
#1 Feb 22nd, 2009
Re: Specifying the bg & hover images of a div using the value supplied in a text box
1
#2 Feb 22nd, 2009
javascript Syntax (Toggle Plain Text)
<html> <head> <title>test</title> <script type="text/javascript"> function applyStyle() { var bgText = document.getElementById('bg').value; var hoverText = document.getElementById('hover').value; var myDiv = document.getElementById('mydiv'); myDiv.style.backgroungImage = "url(" + bgText + ")"; myDiv.onmouseover = function() { alert(hoverText); myDiv.style.backgroungImage = "url(" + hoverText + ")"; } myDiv.onmouseout = function() { alert(bgText); myDiv.style.backgroungImage = "url(" + bgText + ")"; } } </script> <style> #mydiv { border: 1px solid black; width: 100px; height: 100px; } </style> </head> <body > <label>BG:</label><input id="bg" type="text"/> <label>Hover:</label><input id="hover" type="text"/> <input type="button" onClick="applyStyle()" value="apply"> <div id="mydiv"/> </body> </html>
When you think you have done a lot, then be ready for YOUR downfall.
•
•
Join Date: Jan 2009
Posts: 33
Reputation:
Solved Threads: 0
Re: Specifying the bg & hover images of a div using the value supplied in a text box
0
#3 Feb 23rd, 2009
•
•
Join Date: Feb 2009
Posts: 10
Reputation:
Solved Threads: 2
Re: Specifying the bg & hover images of a div using the value supplied in a text box
1
#4 Feb 23rd, 2009
•
•
Join Date: Jan 2009
Posts: 33
Reputation:
Solved Threads: 0
Re: Specifying the bg & hover images of a div using the value supplied in a text box
0
#5 Mar 23rd, 2009
Hello,
I have a div with the following code:
I want to change the bg image for the div ' m3_dr', the css for which is given below:
But the above code is not working, do I have to assign an ID to the div, how should this be coded to make it work
Thanks and Regards
Arvind
I have a div with the following code:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<div class="dr"> <div class="dc m_r m_pad" > <div class="m3_dr m3_pad"><span class="m3_h_text">featured products</span></div> </div> </div>
I want to change the bg image for the div ' m3_dr', the css for which is given below:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
.m3_dr { background:url(images/m3-dr.gif) repeat-x top #FFBF00;}
But the above code is not working, do I have to assign an ID to the div, how should this be coded to make it work
Thanks and Regards
Arvind
Re: Specifying the bg & hover images of a div using the value supplied in a text box
0
#6 Mar 23rd, 2009
•
•
Join Date: Jan 2009
Posts: 33
Reputation:
Solved Threads: 0
Re: Specifying the bg & hover images of a div using the value supplied in a text box
0
#7 Mar 25th, 2009
Hello
I added ID to the div, but nothing happens,the code is as below:
The HTML code is as below:
Finally the CSS code is given below:
Can someone tell me if there is anything wrong with this code, and what changes are required to make it work
Thanks and Regards,
Arvind
I added ID to the div, but nothing happens,the code is as below:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
function applystyle_mandiv() { var bgText = document.getElementById('s_bkbgiu').value; var myDiv = document.getElementById('mandiv'); myDiv.style.backgroundImage = "url(" + bgText + ")"; var manName = document.getElementById("in_manImage"); manName.value = "url(" + bgText + ")"; }
The HTML code is as below:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<div id="mandiv" class="dc m1_t" > <div class="dt m1_b" > <div class="dr"> <div class="dc m1_pad" > <span class="m1_h_text">Manufacturers:</span><br> <img alt="" src="images/spacer.gif" width="1" height="12"><br> <select class="sel1"><option> Sony</option></select> </div> </div> </div> </div>
Finally the CSS code is given below:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
.m1_t { background:url(images/m1-t.jpg) no-repeat top;}
Can someone tell me if there is anything wrong with this code, and what changes are required to make it work
Thanks and Regards,
Arvind
Re: Specifying the bg & hover images of a div using the value supplied in a text box
0
#8 Mar 25th, 2009
![]() |
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Disappearing List Bug
- Next Thread: window not resizing?
| Thread Tools | Search this Thread |
acid2 ajax ajaxexample ajaxhelp ajaxjspservlets animate array automatically beta box browser captchaformproblem cart child close codes column css date debugger decimal dependent design disablefirebug dom download element embed engine enter error events ext file firefox focus form forms frameworks getselection google gwt gxt hiddenvalue highlightedword hint html htmlform ie7 ie8 iframe index java javascript javascripthelp2020 jawascriptruntimeerror jquery jsp jump libcurl listbox maps masterpage math media menu microsoft mimic mp4 onmouseoutdivproblem onmouseover onreadystatechange paypal pdf php player position post problem programming prototype redirect safari scale scriptlets scroll search security select software sql toggle unicode variables w3c web website window windowofwords \n





