Forum Moderators: open

Message Too Old, No Replies

Changing the background picture depending on a drop down field selecti

         

fototex

8:18 pm on May 19, 2010 (gmt 0)

10+ Year Member



Hi webmasters,

I need to achieve two things upon making a selection from a drop down field:

1) Changing the background picture of a cell.
2) Changing the size of a uploaded foreground picture within the same cell.


<select name=ADDITIONALINFO>
<option value="25 x 25">25 x 25</option>
<option value="35 x 35">35 x 35</option>
<option value="45 x 45">45 x 45</option>
<option value="55 x 55">55 x 55</option>
</select>


Any guidance how to achieve this is appreciated.

whoisgregg

9:39 pm on May 20, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Could you post the code you've tried so far? :)

If you can get the code even half-way working, we can more easily show you how to take it the rest of the way. Otherwise, we are coding from scratch and might not even understand what you're really after.

MichaelBluejay

2:24 pm on May 25, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Here's one way:

<select name=ADDITIONALINFO onchange=chooseItem(this.options[this.selectedIndex].value)> 
<option value="25-25-red">25 x 25</option>
<option value="35-35-green">35 x 35</option>
</select>

<table border=1 cellpadding=10><tr><td id=cell><img src=pic.jpg id=thePic></td></tr></table>

<script type=text/javascript>
function chooseItem(theSelection) {
values=theSelection.split('-');
document.getElementById('thePic').style.width=values[0]+'px';
document.getElementById('thePic').style.height=values[1]+'px';
document.getElementById('cell').style.background=values[2];
}
</script>

fototex

6:35 pm on Jun 2, 2010 (gmt 0)

10+ Year Member



Thank you very much