Solved

Checkboxes

Posted on 1999-01-26
5
171 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

756 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