473,324 Members | 2,179 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Dynamic Display of Radio/Checkboxes

Relative newbie here,

I'm looking to display the value of radio buttons and check boxes on the
page before submission. So far I can do most of it. When "Hat" is checked
there are to be no color options available. Click on shirt or pants, you
have three options, (actually four if you chose "None"). Shirts and pants
can have multiple colors.

OK, here is the issue, if you choose a color then change your mind and then
un-check the box, it doubles up the 'display' on the page ("strCavTop"). I
want it to clear the 'display' ("strCavTop") of that one value if the box is
clicked to un-check it.

Is there another way to display the data other than a form text box, like a
table cell or something similar? I willing to bet there is a more
economical way to do this, so if there is I'm open to any suggestions.

Thanks Much,

Scott

(Code below)

<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
function GreyOut() {
chk=document.forms[0]
{
chk.NONE. checked=false;
chk.NONE. disabled=true;
chk.BLUE. disabled=true;
chk.RED. disabled=true;
chk.WHITE. disabled=true;
}
}
////////////////////////////////////////////////////////////////////////////
//////////////////////
function Disab(val) {
frm=document.forms[0]
if(val=="HAT")
{
frm.NONE. disabled=true;
frm.BLUE. disabled=true;
frm.RED. disabled=true;
frm.WHITE. disabled=true;
frm.NONE. checked=true;
frm.BLUE. checked=false;
frm.RED. checked=false;
frm.WHITE. checked=false;
frm.strClassTop.value="HAT";
frm.strCavTop.value="";
}

if(val=="SHIRT")
{
frm.NONE. disabled=false;
frm.BLUE. disabled=false;
frm.RED. disabled=false;
frm.WHITE. disabled=false;
frm.NONE. checked=true;
frm.BLUE. checked=false;
frm.RED. checked=false;
frm.WHITE. checked=false;
frm.strClassTop.value="SHIRT";
frm.strCavTop.value="";
}

if(val=="PANTS")
{
frm.NONE. disabled=false;
frm.BLUE. disabled=false;
frm.RED. disabled=false;
frm.WHITE. disabled=false;
frm.NONE. checked=true;
frm.BLUE. checked=false;
frm.RED. checked=false;
frm.WHITE. checked=false;
frm.strClassTop.value="PANTS";
frm.strCavTop.value="";
}

if(val=="NONE")
{
frm.NONE. disabled=false;
frm.NONE. checked=true;
frm.BLUE. checked=false;
frm.RED. checked=false;
frm.WHITE. checked=false;
frm.strCavTop.value="";
}

if(val=="BLUE")
{
frm.NONE. disabled=false;
frm.NONE. checked=false;
}

if(val=="RED")
{
frm.NONE. disabled=false;
frm.NONE. checked=false;
}

if(val=="WHITE")
{
frm.NONE. disabled=false;
frm.NONE. checked=false;
}
}
////////////////////////////////////////////////////////////////////////////
/////////////////////
function makeBlue() {
frm=document.forms[0]
{
frm.strCavTop.value=frm.strCavTop.value+"//BLUE";
}
}

function makeRed() {
frm=document.forms[0]
{
frm.strCavTop.value=frm.strCavTop.value+"//RED";
}
}

function makeWhite() {
frm=document.forms[0]
{
frm.strCavTop.value=frm.strCavTop.value+"//WHITE";
}
}
////////////////////////////////////////////////////////////////////////////
/////////////////////
</SCRIPT>
</HEAD>
<BODY BGCOLOR="white" onLoad="GreyOut()">
<FORM NAME="frmMyForm">

<table border="0" width="100%" height="100%" cellspacing="0"
cellpadding="0">
<tr>
<td>
<INPUT TYPE="text" NAME="strClassTop" style="border: 1px solid #FFFFFF;
background-color: #FFFFFF; color:#FF0000; text-align:right" size="21"><INPUT
TYPE="text" NAME="strCavTop" style="border: 1px solid #FFFFFF;
background-color: #FFFFFF; color:#FF0000; text-align:left" size="50"></td>
</tr>
<tr>
<td valign="top">
<div align="center">
<table>
<tr>
<td align="right">HAT</td>
<td align="left">
<input name="classification" type="radio" value="HAT"
onClick="Disab(this.value)"><input type="hidden" name="class"></td>
<td>&nbsp;</td>
<td align="right">None</td>
<td>
<input type="checkbox" value="NONE" name="NONE"
OnClick="Disab(this.value)"></td>
</tr>
<tr>
<td align="right">SHIRT</td>
<td align="left">
<input name="classification" type="radio" value="SHIRT"
onClick="Disab(this.value)"></td>
<td>&nbsp;</td>
<td align="right">BLUE</td>
<td>
<input type="checkbox" value="BLUE" name="BLUE" onClick="Disab(this.value),
makeBlue()"></td>
</tr>
<tr>
<td align="right">PANTS</td>
<td align="left">
<input name="classification" type="radio" value="PANTS"
onClick="Disab(this.value)"></td>
<td>&nbsp;</td>
<td align="right">RED</td>
<td>
<input type="checkbox" value="RED" name="RED" onClick="Disab(this.value),
makeRed()"></td>
</tr>
<tr>
<td align="right">&nbsp;</td>
<td align="left">
&nbsp;</td>
<td>&nbsp;</td>
<td align="right">WHITE</td>
<td>
<input type="checkbox" value="WHITE" name="WHITE"
onClick="Disab(this.value), makeWhite()"></td>
</tr>
</table>
</div>
</td>
</tr>
<tr>
<td align="left">
</tr>
</table>
</FORM>

</BODY>
</HTML>


Jul 23 '05 #1
3 2168

Scott <no************@hotmail.com> wrote in message
news:41********@news1.prserv.net...
Relative newbie here,

I'm looking to display the value of radio buttons and check boxes on the
page before submission. So far I can do most of it. When "Hat" is checked
there are to be no color options available. Click on shirt or pants, you
have three options, (actually four if you chose "None"). Shirts and pants
can have multiple colors.

OK, here is the issue, if you choose a color then change your mind and then un-check the box, it doubles up the 'display' on the page ("strCavTop"). I want it to clear the 'display' ("strCavTop") of that one value if the box is clicked to un-check it.

Is there another way to display the data other than a form text box, like a table cell or something similar? I willing to bet there is a more
economical way to do this, so if there is I'm open to any suggestions.

Thanks Much,

Scott

Just write a single function called by the onclick event of all the
checkboxes, which always clears the display, then checks the state of all
the checkboxes and appends appropriate text to the textbox.

--
S.C.
Jul 23 '05 #2
Thanks for the help,

This seems to work as a separate function for each checkbox, is this you
meant, or is there a simpler way, other than repeating this function for
each checkbox?

Thanks again,

function checkBlue(val) {

zzz=document.forms[0]

if(zzz.Blue.checked==true)

{

frm.strCavTop.value=frm.strCavTop.value+"//Blue";

}

else if(zzz.Blue.checked==false)

{

frm.strCavTop.value=frm.strCavTop.value.replace("//Blue", "");

}

}



"Scott" <no************@hotmail.com> wrote in message
news:41********@news1.prserv.net...
Relative newbie here,

I'm looking to display the value of radio buttons and check boxes on the
page before submission. So far I can do most of it. When "Hat" is checked
there are to be no color options available. Click on shirt or pants, you
have three options, (actually four if you chose "None"). Shirts and pants
can have multiple colors.

OK, here is the issue, if you choose a color then change your mind and then un-check the box, it doubles up the 'display' on the page ("strCavTop"). I want it to clear the 'display' ("strCavTop") of that one value if the box is clicked to un-check it.

Is there another way to display the data other than a form text box, like a table cell or something similar? I willing to bet there is a more
economical way to do this, so if there is I'm open to any suggestions.

Thanks Much,

Scott

(Code below)

<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
function GreyOut() {
chk=document.forms[0]
{
chk.NONE. checked=false;
chk.NONE. disabled=true;
chk.BLUE. disabled=true;
chk.RED. disabled=true;
chk.WHITE. disabled=true;
}
}
//////////////////////////////////////////////////////////////////////////// //////////////////////
function Disab(val) {
frm=document.forms[0]
if(val=="HAT")
{
frm.NONE. disabled=true;
frm.BLUE. disabled=true;
frm.RED. disabled=true;
frm.WHITE. disabled=true;
frm.NONE. checked=true;
frm.BLUE. checked=false;
frm.RED. checked=false;
frm.WHITE. checked=false;
frm.strClassTop.value="HAT";
frm.strCavTop.value="";
}

if(val=="SHIRT")
{
frm.NONE. disabled=false;
frm.BLUE. disabled=false;
frm.RED. disabled=false;
frm.WHITE. disabled=false;
frm.NONE. checked=true;
frm.BLUE. checked=false;
frm.RED. checked=false;
frm.WHITE. checked=false;
frm.strClassTop.value="SHIRT";
frm.strCavTop.value="";
}

if(val=="PANTS")
{
frm.NONE. disabled=false;
frm.BLUE. disabled=false;
frm.RED. disabled=false;
frm.WHITE. disabled=false;
frm.NONE. checked=true;
frm.BLUE. checked=false;
frm.RED. checked=false;
frm.WHITE. checked=false;
frm.strClassTop.value="PANTS";
frm.strCavTop.value="";
}

if(val=="NONE")
{
frm.NONE. disabled=false;
frm.NONE. checked=true;
frm.BLUE. checked=false;
frm.RED. checked=false;
frm.WHITE. checked=false;
frm.strCavTop.value="";
}

if(val=="BLUE")
{
frm.NONE. disabled=false;
frm.NONE. checked=false;
}

if(val=="RED")
{
frm.NONE. disabled=false;
frm.NONE. checked=false;
}

if(val=="WHITE")
{
frm.NONE. disabled=false;
frm.NONE. checked=false;
}
}
//////////////////////////////////////////////////////////////////////////// /////////////////////
function makeBlue() {
frm=document.forms[0]
{
frm.strCavTop.value=frm.strCavTop.value+"//BLUE";
}
}

function makeRed() {
frm=document.forms[0]
{
frm.strCavTop.value=frm.strCavTop.value+"//RED";
}
}

function makeWhite() {
frm=document.forms[0]
{
frm.strCavTop.value=frm.strCavTop.value+"//WHITE";
}
}
//////////////////////////////////////////////////////////////////////////// /////////////////////
</SCRIPT>
</HEAD>
<BODY BGCOLOR="white" onLoad="GreyOut()">
<FORM NAME="frmMyForm">

<table border="0" width="100%" height="100%" cellspacing="0"
cellpadding="0">
<tr>
<td>
<INPUT TYPE="text" NAME="strClassTop" style="border: 1px solid #FFFFFF;
background-color: #FFFFFF; color:#FF0000; text-align:right" size="21"><INPUT TYPE="text" NAME="strCavTop" style="border: 1px solid #FFFFFF;
background-color: #FFFFFF; color:#FF0000; text-align:left" size="50"></td>
</tr>
<tr>
<td valign="top">
<div align="center">
<table>
<tr>
<td align="right">HAT</td>
<td align="left">
<input name="classification" type="radio" value="HAT"
onClick="Disab(this.value)"><input type="hidden" name="class"></td>
<td>&nbsp;</td>
<td align="right">None</td>
<td>
<input type="checkbox" value="NONE" name="NONE"
OnClick="Disab(this.value)"></td>
</tr>
<tr>
<td align="right">SHIRT</td>
<td align="left">
<input name="classification" type="radio" value="SHIRT"
onClick="Disab(this.value)"></td>
<td>&nbsp;</td>
<td align="right">BLUE</td>
<td>
<input type="checkbox" value="BLUE" name="BLUE" onClick="Disab(this.value), makeBlue()"></td>
</tr>
<tr>
<td align="right">PANTS</td>
<td align="left">
<input name="classification" type="radio" value="PANTS"
onClick="Disab(this.value)"></td>
<td>&nbsp;</td>
<td align="right">RED</td>
<td>
<input type="checkbox" value="RED" name="RED" onClick="Disab(this.value),
makeRed()"></td>
</tr>
<tr>
<td align="right">&nbsp;</td>
<td align="left">
&nbsp;</td>
<td>&nbsp;</td>
<td align="right">WHITE</td>
<td>
<input type="checkbox" value="WHITE" name="WHITE"
onClick="Disab(this.value), makeWhite()"></td>
</tr>
</table>
</div>
</td>
</tr>
<tr>
<td align="left">
</tr>
</table>
</FORM>

</BODY>
</HTML>

Jul 23 '05 #3

Scott <va*****@attglobal.net> wrote in message
news:41********@news1.prserv.net...
Thanks for the help,

This seems to work as a separate function for each checkbox, is this you
meant, or is there a simpler way, other than repeating this function for
each checkbox?

Thanks again,

I was thinking more of having a single function to reprise the whole form
whenever any element changes, taking parameters where necessary to indicate
the most recent action:
<HTML>
<HEAD>
<SCRIPT TYPE="text/JavaScript">

function scanForm(action)
{
var frm=document.forms[0],
fElem=frm.elements['classification'],
rad="",
colours=["RED","WHITE","BLUE"],
i;

for(i=0; i<fElem.length && !fElem[i].checked; i++)
;
if(i!= fElem.length)
rad=fElem[i].value;

frm.strCavTop.value=rad+" ";

for(i=0; i<frm.elements.length; i++)
{
if(frm.elements[i].type=='checkbox')
{
if(action=='classification')
frm.elements[i].checked=false;

if(rad=='HAT')
{
if(frm.elements[i].value=='NONE')
frm.elements[i].checked=true;
else
frm.elements[i].checked=false;

frm.elements[i].disabled=true;
}
else
{
frm.elements[i].disabled=false;

for(var j=0; j<colours.length; j++)
if(frm.elements[i].value==colours[j] && frm.elements[i].checked )
if(action=='NONE')
frm.elements[i].checked=false;
else
{
frm.elements['NONE'].checked=false;
frm.strCavTop.value+="//"+frm.elements[i].value;
}
}
}
}
}

</SCRIPT>
</HEAD>
<BODY BGCOLOR="white" onLoad="scanForm()">
<FORM NAME="frmMyForm">

<table border="0" width="100%" height="100%" cellspacing="0"
cellpadding="0">
<tr>
<td>
<INPUT TYPE="text" NAME="strClassTop" style="border: 1px solid #FFFFFF;
background-color: #FFFFFF; color:#FF0000; text-align:right" size="21"><INPUT
TYPE="text" NAME="strCavTop" style="border: 1px solid #FFFFFF;
background-color: #FFFFFF; color:#FF0000; text-align:left" size="50"></td>
</tr>
<tr>
<td valign="top">
<div align="center">
<table>
<tr>
<td align="right">HAT</td>
<td align="left">
<input name="classification" type="radio" value="HAT"
onClick="scanForm(this.name)"><input type="hidden" name="class"></td>
<td>&nbsp;</td>
<td align="right">None</td>
<td>
<input type="checkbox" value="NONE" name="NONE"
OnClick="scanForm(this.checked?this.value:'')"></td>
</tr>
<tr>
<td align="right">SHIRT</td>
<td align="left">
<input name="classification" type="radio" value="SHIRT"
onClick="scanForm(this.name)"></td>
<td>&nbsp;</td>
<td align="right">BLUE</td>
<td>
<input type="checkbox" value="BLUE" name="BLUE" onClick="scanForm()"></td>
</tr>
<tr>
<td align="right">PANTS</td>
<td align="left">
<input name="classification" type="radio" value="PANTS"
onClick="scanForm(this.name)"></td>
<td>&nbsp;</td>
<td align="right">RED</td>
<td>
<input type="checkbox" value="RED" name="RED" onClick="scanForm()"></td>
</tr>
<tr>
<td align="right">&nbsp;</td>
<td align="left">
&nbsp;</td>
<td>&nbsp;</td>
<td align="right">WHITE</td>
<td>
<input type="checkbox" value="WHITE" name="WHITE"
onClick="scanForm()"></td>
</tr>
</table>
</div>
</td>
</tr>
<tr>
<td align="left">
</tr>
</table>
</FORM>

</BODY>
</HTML>

--
S.C.
http://makeashorterlink.com/?H3E82245A

Jul 23 '05 #4

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

Similar topics

1
by: sman | last post by:
Hi, I recently read this article on About.com on how to create required fields for a form: http://javascript.about.com/library/scripts/blformvalidate.htm Everything works great except that there...
10
by: DettCom | last post by:
Hello, I would like to be able to display or hide fields based on whether a specific Yes/No radio button is selected. This is in conjunction with a posting a just made here in the same group...
4
by: Steph | last post by:
Hello, Can someone tell me the script to use for having a change on the same page when using checkbox function ? For example, i would to check one condition and display dynamically a button...
3
by: ewitkop90 | last post by:
Here is my code: <SCRIPT> function transportchange(transport) { if (framenewinstall.Helpdesk.checked) framenewinstall.Helpdesk.checked=false; if (framenewinstall.CircuitNumber.checked)...
6
by: Craig Keightley | last post by:
I have a page that has n number of radio groups (yes/No) how can i prevent the form being submitted if more than one radio group is not selected? By default all radio groups are unchecked ...
3
by: Leo J. Hart IV | last post by:
OK, here's another question for the experts: I am building a multi-step (3 steps actually) form using a panel for each step and hiding/displaying the appropriate panel/panels depending on which...
10
by: Jen | last post by:
I have a form that has two radio buttons. When the first one is clicked, I would like the page to refresh (keeping the form data in tact) and then displaying 2 new fields that need to be filled...
7
by: Jerim79 | last post by:
My situation is that I have a form that asks the user for a number. Next, I execute a while loop that displays a group of questions the amount of times the customer entered. For instance, the loop...
3
by: creative1 | last post by:
Here is how you create a complex data report that involves parent and child commands and you can update information at runtime. Its pretty straight forward to work with simple queries; however,...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.