Images for Radio Buttons
9 Message(s) by 4 Author(s) originally posted in cfml discussion
| From: trojnfn |
Date: Wednesday, October 24, 2007
|
In my cfform, I have three radio
button s :
Priority
<br>
<CFINPUT type="radio" name="priority" value="1"> 1
<br>
<CFINPUT type="radio" name="priority" value="2"> 2
<br>
<CFINPUT type="radio" name="priority" value="3"> 3
<br>
My action page takes the value of the priority and then does some cfsets,
calculations, etc., then inserts into a table. So far so good.
Now I get a requirement to replace the three radio buttons with three
color ed
image s (to make them stand out on the
screen ).
So if I
click on the first image that represents priority 1, then I need to
capture that value and send to my action page for processing. If I click on
image 2, then send value 2, etc. It needs to work exactly like the radio
buttons so that only one value is selected and sent. Since the images will
replace the buttons and
text (1, 2, 3), I need to somehow indicate and/or
display which image was selected.
Is any of this possisble to do ? If yes, can somebody please show me how to do
it ?
thanks
| From: Grizzly9279 |
Date: Thursday, October 25, 2007
|
This really hasn'thing to do with Cold Fusion, but as one web
developer to
another, let's see if I can get you pointed in the right direction.
I'd use a single, "hidden" form
field to
track a priority value. I'd
display 3 icons, that each have an "onClick"
event to set the hidden priority
field to a value of 1, 2, or 3. If it looks okay from a UI perspective, you
could do something as simple as using
CSS to gray-out the icons of the priority
values that aren't currently selected.
The following is a really quick & dirty example I threw together, I hope it
helps.
(note: I didn't use
<CFFORM> since it was not really necessary for the
purposes of this example)
<html>
<head>
<title>Test Form
</title>
<script language="JAVAScript">
function setPriority( x ){
document.inputForm.priority.value = x;
updateIconStatus();
}
function updateIconStatus(){
var curPriority = parseInt( document.inputForm.priority.value );
var icon_p1 = document.getElementById('icon_p1');
var icon_p2 = document.getElementById('icon_p2');
var icon_p3 = document.getElementById('icon_p3');
switch( curPriority ){
case 1:
icon_p1.style.filter='none';
icon_p2.style.filter='gray';
icon_p3.style.filter='gray';
break;
case 2:
icon_p1.style.filter='gray';
icon_p2.style.filter='none';
icon_p3.style.filter='gray';
break;
case 3:
icon_p1.style.filter='gray';
icon_p2.style.filter='gray';
icon_p3.style.filter='none';
break;
default:
icon_p1.style.filter='gray';
icon_p2.style.filter='gray';
icon_p3.style.filter='gray';
}
}
</script>
</head>
<body onLoad="updateIconStatus();">
<p>Please select a priority:
</p>
<form name="inputForm" method ="post" action="">
<input type="hidden" name="priority" value="1">
<img src="http://www.icongalore.com/images/ni_wm_gifs/ni0013-48.gif"
width="68" height="68" id="icon_p1" alt="Priority 1" style="filter: gray;"
onMouseOver="this.style.cursor='hand';" onClick="setPriority(1);"><br>
<img src="http://www.icongalore.com/images/ni_wm_gifs/ni0017-48.gif"
width="68" height="68" id="icon_p2" alt="Priority 2" style="filter: gray;"
onMouseOver="this.style.cursor='hand';" onClick="setPriority(2);"><br>
<img src="http://www.icongalore.com/images/ni_wm_gifs/ni0022-48.gif"
width="68" height="68" id="icon_p3" alt="Priority 3" style="filter: gray;"
onMouseOver="this.style.cursor='hand';" onClick="setPriority(3);"><br>
<br><br>
<input type="submit" name="submitBtn" value="Submit">
</form>
</body>
</html>
| From: GArlington |
Date: Thursday, October 25, 2007
|
wrote in message:
In my cfform, I have three radio buttons :
Priority <br>
<CFINPUT type="radio" name="priority" value="1"> 1
<br>
<CFINPUT type="radio" name="priority" value="2"> 2
<br>
<CFINPUT type="radio" name="priority" value="3"> 3
<br>
My action page takes the value of the priority and then does some cfsets,
calculations, etc., then inserts into a table. So far so good.
Now I get a requirement to replace the three radio buttons with three colored
images (to make them stand out on the screen).
So if I click on the first image that represents priority 1, then I need to
capture that value and send to my action page for processing. If I click on
image 2, then send value 2, etc. It needs to work exactly like the radio
buttons so that only one value is selected and sent. Since the images will
replace the buttons and text (1, 2, 3), I need to somehow indicate and/or
display which image was selected.
Is any of this possisble to do ? If yes, can somebody please show me how to do
it ?
thanks
Easier still:
<form>
<label for="this_id"><img src="yourImage.gif" /></label>
<input id="this_id" type="checkbox" value="1" />
</form>
Try it...
| From: GArlington |
Date: Thursday, October 25, 2007
|
wrote in message:
In my cfform, I have three radio buttons :
Priority <br>
<CFINPUT type="radio" name="priority" value="1"> 1
<br>
<CFINPUT type="radio" name="priority" value="2"> 2
<br>
<CFINPUT type="radio" name="priority" value="3"> 3
<br>
My action page takes the value of the priority and then does some cfsets,
calculations, etc., then inserts into a table. So far so good.
Now I get a requirement to replace the three radio buttons with three colored
images (to make them stand out on the screen).
So if I click on the first image that represents priority 1, then I need to
capture that value and send to my action page for processing. If I click on
image 2, then send value 2, etc. It needs to work exactly like the radio
buttons so that only one value is selected and sent. Since the images will
replace the buttons and text (1, 2, 3), I need to somehow indicate and/or
display which image was selected.
Is any of this possisble to do ? If yes, can somebody please show me how to do
it ?
thanks
And I believe that you can make the check boxes hidden...
| From: CFMXPrGrmR |
Date: Thursday, October 25, 2007
|
Or you could just CSS...
<input name="priority" type="radio"
style="list-style-image:images/priority_1.gif" value="1" />
<input name="priority" type="radio"
style="list-style-image:images/priority_2.gif" value="2" />
<input name="priority" type="radio"
style="list-style-image:images/priority_3.gif" value="3" />
| From: Grizzly9279 |
Date: Thursday, October 25, 2007
|
RE: CFMXPRGRMR
Interesing. I'm curious...does that work identically in all browsers? How'd you indicate which image is selected?
| From: trojnfn |
Date: Thursday, October 25, 2007
|
Hello Grizzly, this is excellent ! It does exactly what I want.
I took your
code and put in my images and took out the image height and width.
The only problem that I am having is the initial button display when the screen
is first opened. I have a red button for value 1, yellow for 2 and green for 3,
and'd like that to display on the screen, and then when one color is
selected, the other two are grayed out.. But they all initially display as gray.
I modified your code a little so that all three colors display when the screen
is first opened, but then when one color is selcted, the other two don't gray
out anymore, so I put the code back. Now when the screen is opend, the first
button displayed is red and the other two are grayed out. But when I click on
one, say button 3, it turns yellow and the other two gray out, which is kind of
what I want but not quite.
I need the three buttons to display red (value 1), yellow (value 2) and green
(value 3) when the screen is first oprend. Then when one of the colors is
selected,for example button 2 - yellow (value 2 is passed, which it does), the
red button (value 1) and the green button ( value 3) should gray out. It seems
like I get one or the other. Can you tell me what I am doing wrong ?
Your modified code (which is what I am using now) is below. Thanks for you
help.
| From: Grizzly9279 |
Date: Thursday, October 25, 2007
|
Ah I see what you're trying to do. Try this:
<html>
<head>
<title>Test Form</title>
<script language="JAVAScript">
function setPriority( x ){
document.inputForm.priority.value = x;
updateIconStatus();
}
function updateIconStatus(){
var curPriority = parseInt( document.inputForm.priority.value );
var icon_p1 = document.getElementById('icon_p1');
var icon_p2 = document.getElementById('icon_p2');
var icon_p3 = document.getElementById('icon_p3');
switch( curPriority ){
case 1:
icon_p1.style.filter='none';
icon_p2.style.filter='gray';
icon_p3.style.filter='gray';
break;
case 2:
icon_p1.style.filter='gray';
icon_p2.style.filter='none';
icon_p3.style.filter='gray';
break;
case 3:
icon_p1.style.filter='gray';
icon_p2.style.filter='gray';
icon_p3.style.filter='none';
break;
default:
icon_p1.style.filter='none';
icon_p2.style.filter='none';
icon_p3.style.filter='none';
}
}
</script>
</head>
<body>
<p>Please select a priority:</p>
<form name="inputForm" method="post" action="test_form_action.cfm">
<input type="hidden" name="priority" value="">
<img src="../images/priority_button_1.gif" id="icon_p1" alt="Priority 1"
onMouseOver="this.style.cursor='hand';" onClick="setPriority(1);"><br>
<img src="../images/priority_button_2.gif" id="icon_p2" alt="Priority 2"
onMouseOver="this.style.cursor='hand';" onClick="setPriority(2);"><br>
<img src="../images/priority_button_3.gif" id="icon_p3" alt="Priority 3"
onMouseOver="this.style.cursor='hand';" onClick="setPriority(3);"><br>
<br><br>
<input type="submit" name="submitBtn" value="Submit">
</form>
</body>
</html>
| From: trojnfn |
Date: Thursday, October 25, 2007
|
Hi Grizzly,
Your method is perfect. It does everything that I want.
Thanks alot for your help again. I really appreciate it.
Next Message: HTTPS question
Blogs related to Images for Radio Buttons
javascript timer settimeout
... checkboxes javascript uncheck checkbox javascript uncheck checkboxes javascript uncheck
radio javascript uncheck
radio button javascript uncheck
radio buttons javascript uncheck radiobutton javascript unchecked javascript undefine
...
Document
... da form 4856 military document document.getelementbyid with
radio buttons pen-link documentation sap smartforms documentation robot table-tennis player+document+introduction change document table crm_jest explanation of aia document
...
Document
... http://threebit.net/documentation/dialogic/resourc outfoxed documentary mobile computing applications-documentation iep exit document maryland document.getelementbyid with
radio buttons dismiss motion attached copy documents message
...
flash clock tutorials
flash clock time flash clock tutorial flash clock tutorials flash clocks flash close
button flash close window flash close window
button flash close window script flash clouds flash clouds animation flash clouds effect flash clouds
...
html thumbnail creator 1.20
html thumbnail creator 1.20 html thumbnail gallery html thumbnail gallery generator html thumbnail image html thumbnail
images html thumbnail picture html thumbnail pictures html thumbnail viewer html thumbnails html thumbnails code
...
cold fusion hosting reseller
... cold fusion query
cold fusion query a query
cold fusion query of queries
cold fusion query of query
cold fusion query query
cold fusion query to array
cold fusion query to list
cold fusion querystring
cold fusion radio button cold ...