Click here to Skip to main content
15,896,118 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
This is my html
HTML
</head>
<body>
    <div id="outer">
        <div id="header">
        <table>
            <tr>
                <td>Enter your ToDo List</td>
                <td>  <input type="text"  id="target"/><br /></td>
               <td> <input id="Button1"  type="button" value="OK" /></td>
               <!-- <td>
                  </td>-->
            </tr>
        </table>
       </div>
        <div id="message">
            
        </div>
    </div>
</body>
</html>


this is my javascript

JavaScript
Office.initialize = function (reason) {
  

    $('#Button1').click(function () {
        $("#message").append("<br />" + "<input type='checkbox' id='checkbox2' name='test1' />" + document.getElementById("target").value) + "<br />";
        
    });
}

here my program takes user input and writes it in a check box
now i want to put those inputs in an array and display the newest input from user at the top

can any one please help me ?

Thank you !
Posted
Updated 11-Apr-13 3:21am
v2
Comments
Chinmaya C 11-Apr-13 6:28am    
instead of .append(), why don't you use prepend() method.
successft9 11-Apr-13 6:32am    
what does prepend() do ?
Chinmaya C 11-Apr-13 6:42am    
basically .append() add the elements to the last and .prepend() add the element as the first element.
successft9 11-Apr-13 9:34am    
Thank you so much Chinmaya it worked :D
Richard C Bishop 11-Apr-13 9:57am    
Post this as the solution as it is the correct one.

1 solution

//HTML











//Js
Office.initialize = function (reason) {


$('#Button1').click(function () {
$("#message").prepend("
" + "" + document.getElementById("target").value) + "
";

});
}



The solution to my question.
 
Share this answer
 
Comments
Chinmaya C 11-Apr-13 11:22am    
Please mark this question as solved so that it will be shown as solved and help others. :)

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