Solved

Checkboxes

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
hosting images 4 27
How would I do a website like this? 5 54
Change div area and length 1 26
Outlook opens HTML email as text 4 22
Someone recently asked me about how to display a progress indicator on a page while an iframe is loading. And I remember when I first came across this myself. It was a bit tricky to get my head around, but really, it's very simple. The most impor…
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…
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

806 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