Jump to content

jimbob_2011

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

jimbob_2011's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hello, I've got a form and some script with adds new rows contenting item name, qty and the price. What I would like to be able to do, is add the extra rows, calculate the total and then display it. This is the script ... <script type="text/javascript"> $(document).ready(function(){ var counter = 2; $("#add").click(function () { if(counter==31){ alert("Limit of 30 has been reached"); return false; } $("#textBoxes").html($("#textBoxes").html() + "<div id='d"+counter+"' class='invoice_row'><div class='invoice_row_item'><input name='row["+counter+"]' type='textbox' id='row"+counter+"' class='invoice_input'></div><div class='invoice_row_qty'><input name='qty["+counter+"]' type='textbox' id='qty"+counter+"' class='invoice_input' value='1'></div><div class='invoice_row_price'><input name='price["+counter+"]' type='textbox' id='price"+counter+"' class='invoice_input'></div></div>\n"); ++counter; }); $("#remove").click(function () { if(counter==2){ alert("At least 1 box must be present"); return false; } --counter; $("#d"+counter).remove(); }); }); </script> the above then gets added on to this ... <div id='d1' class="invoice_row"> <div class="invoice_row_item"><input name="row[1]" type="textbox" id="row1" class="invoice_input"></div> <div class="invoice_row_qty"><input name="qty[1]" type="textbox" id="qty1" class="invoice_input" value="1"></div> <div class="invoice_row_price"><input name="price[1]" type="textbox" id="price1" class="invoice_input"></div> </div> Thanks for any help!
  2. Ok then, I'll create a new table, then run the foreach loop to add each row into that table. Cheers.
  3. Why serialize() it? Just store the id, price, qty in those columns in rows. I wanted to store the data in 1 place, rather then having a load of columns. I'm allowing upto 30 rows on the invoice, so would that mean I'd need 90 columns? Cheers.
  4. Thats great! My plan is to serialize the data to store it in the database, does that sound ok? How would I serialize that now, before I used, which seemed to work ... $items = serialize($_POST['row']); What would the code be now? Sorry for being a pain! Jim
  5. .... sorry! The HTML ... <div id='d1' class="invoice_row"> <div class="invoice_row_item"><input name="row[1]" type="textbox" id="row1" class="invoice_input"></div> <div class="invoice_row_qty"><input name="qty[1]" type="textbox" id="qty1" class="invoice_input" value="1"></div> <div class="invoice_row_price"><input name="price[1]" type="textbox" id="price1" class="invoice_input"></div> </div> That then just repeats for as many invoice lines as I fancy. On the PHP side of things all I have I just the loop I've tried, which is ... foreach($_POST['row'] as $id=>$data){ echo $data .'-'. $id .'<br>'; } Thanks, Jim
  6. Hi all, Hopefully this will be a very easy question for one of you! Basically, I've created a little invoice script, and I need some help with the invoice data (i.e the item info, qty and the price). My question is how do i deal with the data from multiple rows containing 3 text fields each (item, qty and price). I've been playing with a foreach loop, which I can make echo info in the item field for each row. How do I incorporate the other fields (the qty and price)? Can I build an array to hold it all? Thanks for any help! Jim
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.