Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Sep 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Show array of messages to user

    Folks, i have the following scenario. Hope you can help me with.

    On HTML page i have several checkboxes.
    Then by clicking in a button i call for a javascript function that scan all checkboxes and build a array with the checkboxes values.

    Now i want to display to the user the content of this array. It can be as ALERT (with multiple lines) or send the content of the array to another blank page.

    Can someone help me with an example on how to achieve this ?

    thanks!

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Despite the similar sounding names, Java is not the same as Javascript.
    Moving from Java forum to Javascript forum.

  • #3
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,930
    Thanks
    56
    Thanked 552 Times in 549 Posts
    a simple example...

    Code:
    <body>
    <input type="checkbox" value="hi" onclick="addMess(this)"/><br>
    <input type="checkbox" value="bye" onclick="addMess(this)"/><br>
    <input type="checkbox" value="later" onclick="addMess(this)"/><br>
    <input type="button" value="show me" onclick="alert(str)"/>
    <script type = "text/javascript">
    var str=""
    function addMess(box){
    str=box.checked?str+box.value+"\n":str.replace(box.value+"\n","");
    }
    </script>
    </body>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •