[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Checkboxes

Posted on 1999-01-26
5
Medium Priority
?
176 Views
Last Modified: 2010-04-09
hi,

How do i define a value of the checkbox. FOr example if a check box is checked then the value should be 'Yes' else 'No'

Thanks Aseem
0
Comment
Question by:aseem072898
5 Comments
 
LVL 2

Expert Comment

by:jedimike
ID: 1845659
you put a "checked" inside
<input type=....    checked>

that's all...dont forget to set the value too.
0
 
LVL 4

Expert Comment

by:martinag
ID: 1845660
 <FORM ACTION="script.cgi">
  <INPUT TYPE="CHECK" NAME="chk1" VALUE="Yes">Check it!
  </FORM>
sends "chk=Yes" to the CGI script if it is checked. If it's unchecked, nothing's sent.

Hmmm...maybe that's not what you meant...Is this?
<SCRIPT LANGUAGE="JavaScript">
<!--
function getString(checkbox) {
  return (checkbox.checked) ? "Yes" : "No";
}
alert(getString(document.aForm.aCheckbox)); // Display either "Yes" or "No".
// -->
</SCRIPT>

Please explain if this doesn't help.

Martin
0
 

Author Comment

by:aseem072898
ID: 1845661
Sorry,

Neither of you guys understood what i ment. I am making a Javascript in which 'yes' or 'no' is printed  in a textarea. If the guy checks the checkbox then 'yes' is printed or else 'no' is printed.

Thanks
Aseem
0
 
LVL 4

Expert Comment

by:martinag
ID: 1845662
<INPUT ... onClick="this.form.thatTextBox.value=((this.checked)?'Yes':'No')">

Martin
0
 
LVL 3

Accepted Solution

by:
SuperMario earned 20 total points
ID: 1845663
Use the javascript that was provided in martinag's comment. In the textarea where you want the answer to be displayed, use this:

-script-
if(checkbox.checked)
{
document.write('Yes')
}

or something like that.


0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question