Switching images in cells...

This is a discussion on "Switching images in cells..." within the JavaScript Forum section. This forum, and the thread "Switching images in cells... are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Sep 3rd, 2006, 19:33
New Member
Join Date: Sep 2006
Location: Illinois
Age: 19
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Switching images in cells...

I'm trying to change images that appear in table cells based on two select menus. I know how to get the options from the select menu and test it thru if statemtents. How do I switch images in cells. Here's what I've gotten so far:
PHP: Select all

<head>
<
script type="text/JavaScript">
function 
do_this()
{
 var 
optionOne document.form1.selectOne.value;
 var 
optionTwo document.form1.selectTwo.value;
  if(
optionOne == "1" && optionTwo == "a")
  {
    
//replace the image in cell_1 with another image
  
}
  else if(
optionOne == "1" && optionTwo == "b")
  {
    
//replace the image in cell_2 with another image
  
}
</script>
</head>
<body>
<table border=1>
<form name="form1">
  <tr>
    <td><select name=selectOne>
 <option value="1">1</option>
 <option value="2">2</option>
 <option value="3">3</option></select></td>
    <td><select name=selectTwo>
 <option value="a">A</option>
 <option value="b">B</option>
 <option value="c">C</option></select></td>
  </tr>
  <tr height=50>
    <td width=150 id="cell_1"><img src="IMAGE1"></td>
    <td width=150 id="cell_2"><img src="IMAGE2"></td>
  </tr>
  <tr>
    <td colspan=2><input type=button value="submit" onclick="do_this()"></td>
  </tr>
</form>
</table>
</body> 
What goes in the if statemtents to switch an image in a cell?

Thanks for the help!
Reply With Quote

  #2 (permalink)  
Old Sep 3rd, 2006, 22:03
Most Reputable Member
Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,310
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Skype™ to ukgeoff
Re: Switching images in cells...

Try giving the img tag an id then use;

document.getElementById('imgID').src = 'new image url';
Reply With Quote
  #3 (permalink)  
Old Sep 3rd, 2006, 22:33
New Member
Join Date: Sep 2006
Location: Illinois
Age: 19
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Switching images in cells...

Thanks a lot...I got it to work.

Last edited by Kingcobra220; Sep 3rd, 2006 at 22:45. Reason: Figured it out!
Reply With Quote
Reply

Tags
switching, images, cells

Thread Tools

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
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Switching Host Jack Franklin Hosting & Domains 17 Mar 16th, 2008 22:14
switching backgound image pahvi67 JavaScript Forum 4 Jan 16th, 2008 13:27
switching between style sheets cwjones Web Page Design 4 Jul 4th, 2007 17:06
Switching from ASP to ASP.net jsa ASP.NET Forum 1 Nov 27th, 2006 17:26
Rollover Images in diff cells efreeti Web Page Design 6 Jun 16th, 2006 14:04


All times are GMT. The time now is 01:18.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43