Solved

Checkboxes

Posted on 1999-01-26
5
167 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 10 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
This article discusses how to create an extensible mechanism for linked drop downs.
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now