jquery - Send array data to another page using javascript? -
i want send data page using javascript. using "next" button onclick function. want when click button data in textboxes on page send displayed on page using javascript.
<table border="1" id="bill_table" width="50%" align="center" style="border-collapse: collapse" cellspacing="3" cellpadding="5"> <tr style="display:none;"> <td class="style2"> </td> <td class="style2"> <div id="name_div"> <input name="item[]" type="text" id="item" size="20" style="width:100px;"/> </div> </td> <td class="style2"> <input name="job[]" type="text" id="job" size="20" style="width:100px;"/> </td> <td class="style2"> <div id="relation_div"> <input name="rate[]" type="text" id="rate" size="20" style="width:100px;"/> </div> </td> <td class="style2"> </td> </tr> <tr> <td class="style2">sno</td> <td class="style2">item</td> <td class="style2">job charges</td> <td class="style2">rate</td> <td class="style2"> <input name="add_button" type="button" id="add_button" size="20" value="add" style="width:50px" /> </td> </tr> </table> <p align="center"> <input name="submit1" type="submit" value="submit" /> </p>
and javascript m curently using:-
var itemcount = 0; $(document).ready(function() { var objs = []; var temp_objs = []; $("#add_button").click(function() { var html = ""; var obj = { "row_id": itemcount, "item": $("#item").val(), "job": $("#job").val(), "rate": $("#rate").val(), } $("#item").val(''); $("#job").val(''); $("#rate").val(''); // add object objs.push(obj); itemcount++; // dynamically create rows in table html = "<tr id='tr" + itemcount + "'>" + "<td>" + itemcount + "</td>" + "<td><input type='text' name='txt1[]' readonly value='" + obj['item'] + "'/></td>" + "<td><input type='text' name='txt2[]' readonly value='" + obj['job'] + "'/></td>" + "<td><input type='text' readonly name='txt3[]' value='" + obj['rate'] + "'/></td>" + "<td><input type='button' id='" + itemcount + "' value='remove'>" + "</td> </tr>"; //add table $("#bill_table").append( html) // remove button click $("#" + itemcount).click( function() { var buttonid = $(this) .attr("id"); //write logic removing array $("#tr" + buttonid).remove(); }); }); });
you can use jquery serialize function , redirect next page, this
$("form").serialize()
for example form contains this
<form action=""> first name: <input type="text" name="firstname" value="mickey"><br> last name: <input type="text" name="lastname" value="mouse"><br> </form>
so after serialization get
firstname=mickey&lastname=mouse
and use window.location this
window.location="younextpage.html?"+yourserializeddata
Comments
Post a Comment