Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Auto Check a checkbox when user begins typing in textbox

Posted on 2003-11-18
5
Medium Priority
?
368 Views
Last Modified: 2006-11-17
I have a checkbox sitting next to a textbox.  The checkbox tells the form that there is valid information in the textbox.

What I need is if the user begins typing in the textbox without checking the checkbox, the checkbox should automatically become checked.

Sounds easy, but form field manipulation syntax confuses me.

Also, does anyone know of a website where I can learn more about javascript manipulation of form fields?

Thanks in advance.
0
Comment
Question by:ddotson
[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
  • 2
  • 2
5 Comments
 
LVL 10

Accepted Solution

by:
Bustarooms earned 200 total points
ID: 9773122
<input type="textbox" name="myTextbox" onkeyup="this.form.theCheckbox.checked=(this.value != '')?true:false;"><br>
<input type="checkbox" name="theCheckbox">
0
 
LVL 16

Expert Comment

by:jaysolomon
ID: 9773267
you could do without the checkboxes and just do some client siode javascript form validation
0
 

Author Comment

by:ddotson
ID: 9773548
That's true; however, the checkboxes are in use elsewhere in the form, and it is sort of a visual cue more than anything.

I tried Bustaroom's code, but it didn't work.  Here is what I have:

<input type = 'checkbox' name = 'otherEmail' value = 'yes'>
Other: <input type = 'text' name = 'otherEmailText' size = '35' onkeyup='this.form.otherEmail.checked=(this.value != '')?true:false;'>

BTW I am using it in ASP, hence the single quotes.
0
 
LVL 10

Expert Comment

by:Bustarooms
ID: 9773563
then you will need double quotes in the js part

<input type = 'text' name = 'otherEmailText' size = '35' onkeyup='this.form.otherEmail.checked=(this.value != "")?true:false;'>
0
 

Author Comment

by:ddotson
ID: 9773707
That got it.  Thanks-
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
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)
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…

610 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