473,405 Members | 2,415 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,405 software developers and data experts.

Radio and check boxes problems

Sorry if this isn't the correct group, i don't think there is a group
for straight HTML. I am trying to create a type of search engine. There
are two radio buttons at the top, in the middle there is a text box,
with the search button next to it, and at the bottom there are four
check boxes. When the form loads one of the two radio buttons are
selected as the default, what i want is when someone clicks on one of
the four checkboxes, one of the two radio buttons are deselected. The
user is able to select all 4 checkboxes if he/she wishes, but if they
click on a check box, the radio button, depending on which one is
select is deselected. Sorry if thats confusing, I don't know much
javascript, so a in depth example would be nice, here is my code so
far....

<form class="complex-form" name="searchForm" method="post"
action="Directory.asp">
<TABLE border="1" cellspacing="2" summary="Search Form">
<TR>
<TD rowspan="3"><FONT size ="+3" COLOR=blue
face=arial><b>JIFFY</B></FONT>
<FONT size="+2" color="#CCCCCC"
face=arial><B>Search</B></FONT></TD>

<TD><center><input type="radio" name="SearchType" selected disable
Value="Contract" checked> Contract Number
<input type="radio" name="SearchType" disable Value="JON">
Job Order Number (JON)
</center></TD>
</TR>
<TR>
<TD><center><label for="SearchBox"></label>
<input TYPE="text" NAME="SearchBox" id="SearchBox" SIZE="55"
MAXLENGTH="55" value="<%=request("searchwords")%>">
<input type="Submit" Value="Search" class=button>
</center></TD>
</TR>
<TR>
<TD><center><input type="checkbox" name="SearchType" disable
Value="Title"> Title
<input type="checkbox" name="SearchType" disable Value="Scope">
Scope
<input type="checkbox" name="SearchType" disable
Value="Objective"> Objective
<input type="checkbox" name="SearchType" disable
Value="Approach"> Approach
</center></TD>
</TABLE>
</form>
Thank you any help will be greatly appreciated,
Jimmie

Jul 23 '05 #1
2 3208
You need to put an onclick handler on each checkbox that reads through
the checkboxes whenever one changes and decides which radio button to
select.

example of one of your checkboxes:

<input id="SearchType" type="checkbox" name="SearchType" disable
Value="Title" onclick="handle_oncheck();">


example javascript:

function handle_oncheck () {
if (document.getElementById('SearchType').getAttribut e('checked') ==
'true') {
document.getElementById('Contract').setAttribute(' checked', 'true');
} else {
document.getElementById('Contract').removeAttribut e('checked');
}
}

Obviously you'll want to put your own logic in that function but that's
an example. And if you are going to do it this way, you'll need to put
a unique id on each of your input elements so you can use
getElementById. For my example to work, you would need one of your
radio buttons to have the id="Contract".

Hope this helps.
Laura.

Jul 23 '05 #2
<ji******@hotmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
Sorry if this isn't the correct group, i don't think there is a group
for straight HTML. I am trying to create a type of search engine. There
are two radio buttons at the top, in the middle there is a text box,
with the search button next to it, and at the bottom there are four
check boxes. When the form loads one of the two radio buttons are
selected as the default, what i want is when someone clicks on one of
the four checkboxes, one of the two radio buttons are deselected. The
user is able to select all 4 checkboxes if he/she wishes, but if they
click on a check box, the radio button, depending on which one is
select is deselected. Sorry if thats confusing, I don't know much
javascript, so a in depth example would be nice, here is my code so
far....

<form class="complex-form" name="searchForm" method="post"
action="Directory.asp">
<TABLE border="1" cellspacing="2" summary="Search Form">
<TR>
<TD rowspan="3"><FONT size ="+3" COLOR=blue
face=arial><b>JIFFY</B></FONT>
<FONT size="+2" color="#CCCCCC"
face=arial><B>Search</B></FONT></TD>

<TD><center><input type="radio" name="SearchType" selected disable
Value="Contract" checked> Contract Number
<input type="radio" name="SearchType" disable Value="JON">
Job Order Number (JON)
</center></TD>
</TR>
<TR>
<TD><center><label for="SearchBox"></label>
<input TYPE="text" NAME="SearchBox" id="SearchBox" SIZE="55"
MAXLENGTH="55" value="<%=request("searchwords")%>">
<input type="Submit" Value="Search" class=button>
</center></TD>
</TR>
<TR>
<TD><center><input type="checkbox" name="SearchType" disable
Value="Title"> Title
<input type="checkbox" name="SearchType" disable Value="Scope">
Scope
<input type="checkbox" name="SearchType" disable
Value="Objective"> Objective
<input type="checkbox" name="SearchType" disable
Value="Approach"> Approach
</center></TD>
</TABLE>
</form>
Thank you any help will be greatly appreciated,
Jimmie


Here's a variation of your code. Watch for word-wrap.

<html>
<head>
<title>engine.htm</title>
<script type="text/javascript">
function SearchTypes(that) {
var form = document.searchForm;
if (that.checked) {
for (var i=0; i<form.SearchType0.length; i++) {
form.SearchType0[i].checked = false;
}
}
}
</script>
<style type="text/css">
td { font-family:Arial; height:32px }
th { font-family:Arial; font-weight:bold }
..button { background-color: #FFFFFF }
..border { border:solid 1px #AAAAAA }
</style>
</head>
<body>

<form action="Directory.asp" class="complex-form" method="post"
name="searchForm">
<table border="0" cellpadding="0" cellspacing="2" summary="Search Form"
width="700" class="border">
<tr>
<th rowspan="3" width="150">
<font size="+3" color=blue>JIFFY</font><br>
<font size="+2" color="#CCCCCC">Search</font>
</th>
<td align="center">
<input type="radio" name="SearchType0" value="Contract" checked>
Contract Number
<input type="radio" name="SearchType0" value="JON"> Job Order Number
(JON)
</td>
</tr>
<tr>
<td align="center">
<input type="checkbox" name="SearchType1" onclick="SearchTypes(this)"
value="Title"> Title
<input type="checkbox" name="SearchType2" onclick="SearchTypes(this)"
value="Scope"> Scope
<input type="checkbox" name="SearchType3" onclick="SearchTypes(this)"
value="Objective"> Objective
<input type="checkbox" name="SearchType4" onclick="SearchTypes(this)"
value="Approach"> Approach
</td>
</tr>
<tr>
<td align="center">
<input type="text" name="SearchBox" size="55" maxlength="55"
value="<%=request("searchwords")%>">
<input type="Submit" Value="Search" class="button">
</center>
</td>
</tr>
</table>
</form>

</body>
</html>

What do you want to happen if the select a radio button after checking a
checkbox?

You could disable the radio buttons if any check box is checked.
Jul 23 '05 #3

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

Similar topics

3
by: elhombrebala | last post by:
With this script I can force the user to select the checkbox befor continuing, but now I have a menu with lots of radio unputs and I woul like the user to select at least 2 of them; how can I check...
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...
4
by: Jay | last post by:
I have a form used to submit data (no surprises there!). I'd like to be able to populate the same form with previously submitted data. The data lives in a database once submitted and using ASP I...
4
by: Jared | last post by:
Radio Button or Check Box and Event Procedures I need to insert either radio buttons or check boxes onto my form. I'm not sure which to use, or if there are other options. I am using the buttons...
8
by: David Cameron | last post by:
I noticed that using an HTMLInputRadioButton and specifying a value to be an empty string (""), this is overridden by ASP.Net which set the value of the control to be the same as the ID of the...
2
by: Pauly | last post by:
I have a group of three radio buttons on a group box. In my database I have three columns all of data type bit. I want to bind each button so that if it is 1 then it selects the appropriate...
2
by: NishSF | last post by:
Would anyone have any suggestions/javascript code so that if one clicks the Radio Button "Yes" below he has the option of selecting any of the six CheckBox below. If the user clicks on Radio Button...
11
by: tracy.cooperjr | last post by:
I have four checkboxes. I want only one of them to be checked at a time. Any ideas?
2
by: AAaron123 | last post by:
You can use RadioButtonRenderer to make a button look like a radio button. Is there a similar way to make check boxes look like radio check boxes? Same about menu items?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
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,...
0
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...
0
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,...
0
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...
0
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...
0
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.