473,769 Members | 2,437 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Swap image with check/uncheck of Radio Button

Hi,
I use a radio button form in which users can select a color by clicking
on a image.
I would like this image to change to another one when it's chosen.
(image with a "Chosen" Stamp in the middle)
Of course I like it to be restored if hte user select another color.

I've tried to add behaviour to the image (swap on click) and on the
button (onchange swap restore) but it doesn't work (hte image id
swapped and restored almost instantly).

Any ideas ?

Mathieu

Jan 8 '07 #1
4 11508
le***@attglobal .net wrote:
Hi,
I use a radio button form in which users can select a color by clicking
on a image.
I would like this image to change to another one when it's chosen.
(image with a "Chosen" Stamp in the middle)
Of course I like it to be restored if hte user select another color.

I've tried to add behaviour to the image (swap on click) and on the
button (onchange swap restore) but it doesn't work (hte image id
swapped and restored almost instantly).

Any ideas ?

Mathieu
<input ... onclick=
'if(this.checke d)document.imag es["imageName"].src="chosen.im g"'>
<input ... onclick=
'if(this.checke d)document.imag es["originalImageN ame"].src="original. img"'>
Mick
Jan 8 '07 #2
<input ... onclick=
'if(this.checke d)document.imag es["imageName"].src="chosen.im g"'>
<input ... onclick=
'if(this.checke d)document.imag es["originalImageN ame"].src="original. img"'>
Mick
Thank you Mick,

I have 10 radio buttons, i can paste copy ten times the code and be
careful or do a function:
onclick="change images("ImageNa me1")"
but how do transalte document.images["imageName"].src="chosen.im g"' if
i use a java script function.
document.form['myRadioGroup
Name'].images["imageName"].src="chosen.im g"' , it dosen't work.

I want to do a loop on every buttons with the image having a
Nameimage+i name.

mat

Jan 9 '07 #3
i did it !!!

function change(idgroupi mage)
{
for(var i=1;i<3;i++)
{
if (i!=idgroupimag e)
{
eval
('document.form 1.nameimage'+i+ '.src="Photos/GIF/nameimage'+i+'. gif"');
}
else eval
('document.form 1.nameimage'+i+ '.src="Photos/GIF/nameimage'+i+'_ ok.gif"');
}
}

Jan 9 '07 #4
le***@attglobal .net wrote:
i did it !!!

function change(idgroupi mage)
{
for(var i=1;i<3;i++)
{
if (i!=idgroupimag e)
{
eval
('document.form 1.nameimage'+i+ '.src="Photos/GIF/nameimage'+i+'. gif"');
}
else eval
('document.form 1.nameimage'+i+ '.src="Photos/GIF/nameimage'+i+'_ ok.gif"');
}
}
Why not:
function change(idgroupi mage){
for(var i=1;i<3;i++){
document.images["nameimage" +i].src=
"Photos/GIF/nameimage"+i+(i !=idgroupimage? "_ok.gif":".gif ");
}
}
?
Mick

Jan 10 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
18782
by: Jawahar Rajan | last post by:
All, I am using a few Input type of "Image" instead of a classic submit button in a form to achieve various tasks for example image1 - add user image2 - modify user image3 - delete user image4 - reSet user.
6
16286
by: Ken Loomis | last post by:
Hello: On a web page I check the value of a cookie and set one of two radio buttons accordingly. function setRadioForm() { var myCookie = document.cookie; var OpenOnly = myCookie.substring(9); if (OpenOnly == "True") { document.ViewOptions.Open.checked = true;
1
4136
by: Brian Genisio | last post by:
Hi all, I noticed that the image input type does not show up in the elements array (IE 6.0). <FORM name=myForm> <INPUT name=rads id=check1 type=radio value=val1> <INPUT name=rads id=check2 type=radio value=val2 checked> <INPUT name=rads id=check3 type=radio value=val3> <INPUT name=rads id=check4 type=radio value=val4>
2
4491
by: broms10 | last post by:
I need help. I have a little button that says "next" below a big image, let´s call it "image1", when I press the button I want to swap the big image to "image2". And then if I press it again I want it to swap to "image3" and the next time to "image4" and so on. I´m not so good at javascripts but I found a script that can make the button swap "image1" to "image2" when I click it, but the problem comes when I want the same button to swap...
5
2810
by: kid | last post by:
Hi, I have 5 checkbox elements, i.e: ( 1 ) a ( 2 ) b ( 3 ) c ( 4 ) d ( Check/Uncheck all )
1
4085
by: sourcie | last post by:
I am changing an existing quiz found on "JavaScriptKit.com Multiple Choice Quiz" I have an image. Instead of using the radio buttons with the normal true/false question, I want to place two hotspots on the image. One being correct(a) and the other incorrect(b). When the user clicks on the correct hotspot or place on the image, it should score and retain that value until the end of the quiz. At the end of the quiz, there is a submit button...
9
9904
by: ameshkin | last post by:
Hi guys, I'm a pretty good PHP programmer, but when it comes to JS, I just dont understand it! But I really need to learn. I'm having trouble doing the simplest thing! When someone clicks on this image, I want the radiobutton above it to be checked. Not that hard,but nothing I try seems to work. Can someone please help me?
13
3092
by: PhpCool | last post by:
Hi, since sometime I'm stuck in a problem where I want to check or uncheck all the checkboxes. If I'm choosing name for the checkbox array as 'chkbx_ary' then I'm able to check/uncheck all the checkboxes (code pasted below). But if name of the checkbox array is 'chkbx_ary' then it's failing. I want the name to be 'chkbx_ary' because I want to access this array at server side. Though one may not require to see php part but I'm still pasting...
1
5184
by: Anuj | last post by:
Hi, since sometime I'm stuck in a problem where I want to check or uncheck all the checkboxes. If I'm choosing name for the checkbox array as 'chkbx_ary' then I'm able to check/uncheck all the checkboxes (code pasted below). But if name of the checkbox array is 'chkbx_ary' then it's failing. I want the name to be 'chkbx_ary' because I want to access this array at server side. Though one may not require to see php part but I'm still pasting...
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10219
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10049
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9998
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9865
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5310
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3967
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.