Click here to Skip to main content
15,887,329 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900