Click here to Skip to main content
14,267,090 members
Rate this:
Please Sign up or sign in to vote.
See more:
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>
Posted
Updated 26-Jul-18 4:38am
v2
Comments
Richard MacCutchan 26-Jul-18 7:43am
   
You need to get the existing text value, add whatever field separators you need, and then add the new button name. As it stands (as far as I can see) you are just replacing the text field each time.
Richard Deeming 26-Jul-18 10:38am
   
I've removed the tutorials site link from your question, because it makes the question look like spam.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




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