[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

If no checkboxes on page are checked - clear value in textarea

Posted on 2011-09-06
2
Medium Priority
?
169 Views
Last Modified: 2012-05-12
I need to loop through all checkboxes on page - if no are checked - then clear the value on a textfield/area, etc.? I am doing this on the check changed event for a checkbox
0
Comment
Question by:tbaseflug
[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 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 36491222
what is the question? show us your current code
0
 
LVL 17

Accepted Solution

by:
sonawanekiran earned 2000 total points
ID: 36495358
Very simple. Check below code. When you uncheck all checkbox the value in textarea fields get cleared.
You can test below code at

http://jsfiddle.net/Wc4NY/
<!DOCTYPE html>
<html>
<head>
<title>Kiran Test</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript">
 $(document).ready(function(){
 $('input:checkbox').click(function(){
   clear_textarea();
  });
});

function clear_textarea()
{
  var checkbox_flag = false;
  $('input:checkbox').each(function(){
    if($(this).is(':checked'))
      checkbox_flag = true;
  });
  
  if(!checkbox_flag)
    $('#mytextarea').html("");
}

</script>
</head>
<body>
  <form>
  <table>
    <tr>
      <td><input type="checkbox" checked></td>
      <td><input type="checkbox"></td>
      <td><input type="checkbox" checked></td>
      <td><input type="checkbox"></td>
      <td><input type="checkbox" checked></td>
    </tr>
    <tr>
      <td><input type="checkbox"></td>
      <td><input type="checkbox" checked></td>
      <td><input type="checkbox"></td>
      <td><input type="checkbox"></td>
      <td><input type="checkbox" checked></td>
    </tr>
    <tr>
      <td colspan="5">
        <textarea id="mytextarea" cols="30" rows="10">Sample Text Sample Text Sample Text</textarea>
      </td>
    </tr>
  </table>
</form>
</body>
</html>

Open in new window

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

649 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