Click here to Skip to main content
14,268,822 members

Make buttons (or checkbox) and copy values from them to make a list of values

Member 13926561 asked:

Open original thread
hi,
i need to make a simple app with TV programs, names on buttons or checkboxes, and when i click multiple buttons (or select checkboxes) it copies values from them to a textarea that i can then copy and use elsewhere.. For example 5 buttons, each named MTV, MTV2, FOX, CNN, ZDF. when i click for example on 3 of those (MTV, FOX, MTV2) i get in an text area following: MTV; FOX; MTV2 (so i can copy that desired list of TV programms).
i found the code in HTML (below), but i dont know how to make tv program to stay in textarea, each time i click new tv program, it only shows that program, it does not make a list of programms

What I have tried:

<html>
<head>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    <script type="text/javascript">
    $(document).ready(function(){
        $("button").click(function () {
            var text = $(this).text();
            $("input").val(text);
        });
    });
    </script>
    <style>
    .selected { color:red; }
    .highlight { background:yellow; }
    </style>
</head>
<body>
    <div>
        <button>HRT1</button>
        <button>HRT2</button>
        <button>NovaTV</button>
    </div>
    <input type="text" value="click a button" />
</body>
</html>
Tags: copy-paste, Text

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the The Code Project Open License (CPOL).




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100