Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-14-2003, 02:36 AM   PM User | #1
pinkcat_02
Regular Coder

 
Join Date: Jan 2003
Posts: 148
Thanks: 0
Thanked 0 Times in 0 Posts
pinkcat_02 is an unknown quantity at this point
Question pop up menu

i want to do a pop up menu where there are 3 options and whatever option is selected the image should change.

i have managed to do the pop up menu but i dunno the bit where it needs to change the image.

i have checked the current codes but they give link to other pages when an option is selected where i want to swap an image.

does anyone knows how to do this?
pinkcat_02 is offline   Reply With Quote
Old 01-14-2003, 02:49 AM   PM User | #2
ez4ne12c
Regular Coder

 
Join Date: Jun 2002
Location: Australia
Posts: 197
Thanks: 0
Thanked 0 Times in 0 Posts
ez4ne12c is an unknown quantity at this point
You need to use innerHTML to change the image without reloading the page..
something like this

define your origional image like this

<span name='dude'><img src='joe.gif'></img></span>

then use your select to change the image

dude.innerHTML='<img src='fred.gif'></img>'
__________________
Animation Rule #64
Poor quality images are often artistic,
Poor quality sound is ALWAYS annoying.
ez4ne12c is offline   Reply With Quote
Old 01-14-2003, 03:22 AM   PM User | #3
tempest1
New Coder

 
Join Date: Nov 2002
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
tempest1 is an unknown quantity at this point
Why not...

<span id='dude'><img src='joe.gif'></span>

then use your select to change the image

document.getElementById("dude").innerHTML='<img src='fred.gif'>';

More Cross-Browser...
__________________
» ð, Ŵħąŧ¿ Ýőų łįķę¿
tempest1 is offline   Reply With Quote
Old 01-14-2003, 03:29 AM   PM User | #4
ez4ne12c
Regular Coder

 
Join Date: Jun 2002
Location: Australia
Posts: 197
Thanks: 0
Thanked 0 Times in 0 Posts
ez4ne12c is an unknown quantity at this point
i dont like to make my browser cross hahaha
Thanks Tempest1
__________________
Animation Rule #64
Poor quality images are often artistic,
Poor quality sound is ALWAYS annoying.
ez4ne12c is offline   Reply With Quote
Old 01-14-2003, 06:20 PM   PM User | #5
pinkcat_02
Regular Coder

 
Join Date: Jan 2003
Posts: 148
Thanks: 0
Thanked 0 Times in 0 Posts
pinkcat_02 is an unknown quantity at this point
well my pop up menu is done by js, i didn't really understand y i should use inner html in js.

can u pls give me an example with full js code so that i can understand better?

thanx
pinkcat_02 is offline   Reply With Quote
Old 01-14-2003, 09:44 PM   PM User | #6
pinkcat_02
Regular Coder

 
Join Date: Jan 2003
Posts: 148
Thanks: 0
Thanked 0 Times in 0 Posts
pinkcat_02 is an unknown quantity at this point
Unhappy

i think u got me wrong. by pop up menu i meant the one when u right click on an image the menu opens and there u have options.once u choose an option it'll change the image and when u click another option it'll change the image as well.

it's not a list menu that we can see in the forms it's a js pop up menu.
pinkcat_02 is offline   Reply With Quote
Old 01-15-2003, 01:19 AM   PM User | #7
whammy
Senior Coder

 
Join Date: Jun 2002
Location: 41° 8' 52" N -95° 53' 31" W
Posts: 3,660
Thanks: 0
Thanked 0 Times in 0 Posts
whammy is an unknown quantity at this point
For that I think you'll need to supply the code you are currently using.
__________________
Former ASP Forum Moderator - I'm back!

If you can teach yourself how to learn, you can learn anything. ;)
whammy is offline   Reply With Quote
Old 01-15-2003, 02:19 AM   PM User | #8
pinkcat_02
Regular Coder

 
Join Date: Jan 2003
Posts: 148
Thanks: 0
Thanked 0 Times in 0 Posts
pinkcat_02 is an unknown quantity at this point
<script language="JavaScript" type="text/JavaScript">function mmLoadMenus() {
if (window.mm_menu_0115002607_0) return;
window.mm_menu_0115002607_0 = new Menu("root",32,18,"",12,"#000000","#FFFFFF","#CCCCCC","#000084","left","middle",3,0,1000,-5,7,true,true,true,0,true,true);
mm_menu_0115002607_0.addMenuItem("a");
mm_menu_0115002607_0.addMenuItem("b",);
mm_menu_0115002607_0.hideOnMouseOut=true;
mm_menu_0115002607_0.bgColor='#555555';
mm_menu_0115002607_0.menuBorder=1;
mm_menu_0115002607_0.menuLiteBgColor='#FFFFFF';
mm_menu_0115002607_0.menuBorderBgColor='#777777';

mm_menu_0115002607_0.writeMenus();
}


in the body:

<body>
<script language="JavaScript1.2">mmLoadMenus();</script>
<div id="Layer1" style="position:absolute; left:363px; top:229px; width:104px; height:83px; z-index:1"><a href="javascript:;" onMouseOver="MM_showMenu(window.mm_menu_0115002607_0,126,81,null,'image1')" onMouseOut="MM_startTimeout();"><img src="v.gif" name="image1" width="129" height="84" border="0" id="image1"></a></div>
</body>


in this code i want when the user choses a option the image 1 will change from x.gif to y.gif

and if the user chooses option b the image 1 changes from x.gif to m.gif


ANy ideas how to do this?
pinkcat_02 is offline   Reply With Quote
Old 01-15-2003, 10:17 PM   PM User | #9
ez4ne12c
Regular Coder

 
Join Date: Jun 2002
Location: Australia
Posts: 197
Thanks: 0
Thanked 0 Times in 0 Posts
ez4ne12c is an unknown quantity at this point
I still reckon
you should try innerHTML
ok you have defined your image (without the closing tag </img>) so i pu that in .. chuck it all in a span and
<span id='blah'><img src="v.gif" name="image1" width="129" height="84" border="0" id="image1"></img></span>

onMouseOver="change_image();MM_showMenu(window.mm_menu_0115002607_0,126,81,null,'image1')"

function change_image()
{
blah.innerHTML='<img src="y.gif" name="image1" width="129" height="84" border="0" id="image1"></img>'
}

something like that should work .. innerHTML doesnt care what menu or object event you use to call the function change_image..
hope this helps
ez

If that doesnt work you could try outerHTML to change the entire Layer1 definition..
__________________
Animation Rule #64
Poor quality images are often artistic,
Poor quality sound is ALWAYS annoying.
ez4ne12c is offline   Reply With Quote
Old 01-15-2003, 10:28 PM   PM User | #10
pinkcat_02
Regular Coder

 
Join Date: Jan 2003
Posts: 148
Thanks: 0
Thanked 0 Times in 0 Posts
pinkcat_02 is an unknown quantity at this point
Unhappy

i have sorted it out now i have another problem that the images next to a particular image covers my menus,,, i have been using layers in dreamweaver if that helps...

thanx 4 the help but what shall i do now???
pinkcat_02 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT +1. The time now is 07:53 AM.


Advertisement
Log in to turn off these ads.