|
| |
|
|
kitty6
Posts: 153 Joined: 10/15/2005 Status: offline
|
radio button to checkbox - 8/20/2008 10:37:23
Does anyone know how to change an option group from a radio button to a checkbox? I changed "radio" to "checkbox" but then the option group does not work the same. It only works like a checkbox. Thanks. <input type="radio" value="V1" name="R2">
|
|
|
|
rdouglass
Posts: 9280 From: Biddeford, ME USA Status: offline
|
RE: radio button to checkbox - 8/20/2008 11:53:13
quote:
then the option group does not work the same. What do you mean by that? What doesn't work the same? In most circumstances they should. If checkboxes have the same name, you can select more than 1 and the POSTed value will be a comma delimited string of the checked values. With a radio group, you can only select one so when multiple checkboxes have the same name, they can usually be trated just as a multi-select radio. Many JS implementations will do the same if you use the "option[]" element. Did that make any sense?
_____________________________
Don't take you're eye off your final destination. ASP Checkbox Function Tutorial.
|
|
|
|
kitty6
Posts: 153 Joined: 10/15/2005 Status: offline
|
RE: radio button to checkbox - 8/20/2008 14:13:19
What I mean is this. When I change the "radio" to "checkbox" it changes it to a checkbox but it then acts like a checkbox and not like an option group. I simply want to change my option group radio button to a checkbox and still mantain the option group functionality. I hope this helps. Thanks. <input type="radio" value="V1" name="R2">
|
|
|
|
kitty6
Posts: 153 Joined: 10/15/2005 Status: offline
|
RE: radio button to checkbox - 8/20/2008 15:07:55
Basically, here is my code that works fine. You can only select on radio button at a time. When I change the word radio to checkbox, it changes it to a checkbox but you now can select both boxes at one time. I want it to act just like the radio buttons do but use checkboxes instead. Is this possible? Thanks. <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>New Page 1</title> <meta name="GENERATOR" content="Microsoft FrontPage 6.0"> <meta name="ProgId" content="FrontPage.Editor.Document"> </head> <body> <form method="POST" action="--WEBBOT-SELF--"> <p><input type="radio" value="V1" name="R1"></p> <p><input type="radio" name="R1" value="V2"></p> <p> </p> <p><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p> </form> </body> </html>
|
|
|
|
rdouglass
Posts: 9280 From: Biddeford, ME USA Status: offline
|
RE: radio button to checkbox - 8/20/2008 15:08:28
I would make them checkboxes and add a JavaScript to deselect all the other checkboxes except the one not checked. If you mean to just style the radio like a box, I don't think it can be done. IIRC The "radio" element is a system element and can only be changed so much; similar to the "select" element and if you want anything too different, you frequently have to use CSS and JS. </$.02>
_____________________________
Don't take you're eye off your final destination. ASP Checkbox Function Tutorial.
|
|
|
|
kitty6
Posts: 153 Joined: 10/15/2005 Status: offline
|
RE: radio button to checkbox - 8/20/2008 15:11:18
I see. I kind of thought that. Thanks for your help.
|
|
|
|
rdouglass
Posts: 9280 From: Biddeford, ME USA Status: offline
|
RE: radio button to checkbox - 8/20/2008 15:29:27
Sorry, I posted that last response while you were typing yours. How about something like this: <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<script language = "Javascript">
<!--
function SetUnCheckAll(elementNumb)
{
dml=document.myform;
len = dml.elements.length;
var i=0;
for( i=0 ; i<len ; i++)
{
if (dml.elements[ i ].name=='checkbox')
{
dml.elements[ i ].checked=0;
if (i == elementNumb)
{
dml.elements[ i ].checked=1;
}
}
}
}
// -->
</script>
</head>
<body>
<form method="POST" action="_vti_bin/shtml.dll/test.htm" name="myform" id="myform" webbot-action="--WEBBOT-SELF--" >
<p><input type="checkbox" name="checkbox" value="V1" onclick="SetUnCheckAll(0);">One</p>
<p><input type="checkbox" name="checkbox" value="V2" onclick="SetUnCheckAll(1);">Two</p>
<p><input type="checkbox" name="checkbox" value="V3" onclick="SetUnCheckAll(2);">Three</p>
<p><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
</form>
</body>
</html> See what I did? EDIT: Sorry the code wants to interpret [ i ] as italics so I''m adding some speaces. so where you see "[ i ]" please remove the spaces
_____________________________
Don't take you're eye off your final destination. ASP Checkbox Function Tutorial.
|
|
New Messages |
No New Messages |
Hot Topic w/ New Messages |
Hot Topic w/o New Messages |
Locked w/ New Messages |
Locked w/o New Messages |
|
Post New Thread
Reply to Message
Post New Poll
Submit Vote
Delete My Own Post
Delete My Own Thread
Rate Posts
|
|
|