Go Back   HTMLCenter Web Development Forums > Web Design and Development > Programming and Scripting

Help with checkbox and image javascript

Closed Thread
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old 11-21-2008, 01:00 AM
Registered User
 
Join Date: Nov 2008
Posts: 1
Smile Help with checkbox and image javascript

Hi people, I'm new to javascripting and i need some help!!
I'm trying to make a script which uses id's and name's to change values and image src's.

What I want, is to be able to select a checkbox, then click an image which then changes the 'src' of the image with the value of the checked checkbox.
AND if it's not too much to ask, i also need help with transferring the image src'es into a text box..
But It's more important that I get the "checkbox-to-image-src" part working.. so please help me with that first. !

I've accomplished similar scripts, but much, much simpler..




Here's the "vibe" and the basic idea of the code i want:

<!-- start code
<HTML>
<HEAD>
<TITLE>test</TITLE>
<script>
fuction CHK() {
var CHECKNAME = "checkbox.checked=true"; // Find checkbox which is checked - need serious help here..
var EXT = ".gif"; // Image file-type to be used in final replacement src
this.src="document.form1.'+ CHKNAME +'.value+EXT"; // Gets value from checkbox, and uses as img.src (replaces the image
}

function CONVERT() {
var sep = ","
CODEBOX.value="document.IMG0.src+sep+document.IMG1 .src+sep+document.IMG2.src+sep+document.IMG3.src" // Basically gets all the image's src, seperated by commas, and get put into the CODEBOX textbox
}

</script>
</HEAD>
<BODY>
<form name=form1>
<img src=0.gif id=IMG0 onclick="CHECK()"><img src=0.gif id=IMG1 onclick="CHECK()"><img src=0.gif id=IMG2 onclick="CHECK()"><img src=0.gif id=IMG3 onclick="CHECK()"><br>
<input type=checkbox value=0 name=chk1>0<input type=checkbox value=1 name=chk2>1<input type=checkbox value=2 name=chk1>2<input type=checkbox value=3 name=chk1>3<br>
<input type="text" id=CODEBOX value=""><input type=submit value="get code" onclick="CONVERT()">
</form>
</BODY>
</HTML>
<!-- end code



If anyone can help me in anyway at all, even just a little, it would help me SO much.
i just to get started with it.


MUCH APPRECIATED!!!

Closed Thread


Thread Tools
Display Modes 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
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT -5. The time now is 10:17 PM.

 
Bitrix
Clicky Web Analytics
Maxtango
CloudContacts


Subscribe to our feed | add to myYahoo!

Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.2.0
© 1997-2007 HTMLCenter