Jump to content

Ravi_Ramsagar

Members
  • Posts

    9
  • Joined

Ravi_Ramsagar's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks for the response.Yes the form itself is not reloaded from the form submit. I tried with document.getElementById('inv').reset(); in the check_counter function but no luck. Actually the form gets reloaded but an empty invoice with no details will be opened in new window as the form gets reloaded on form submit.I want to submit the form that is an complete invoice has to be generated then the form should get reloaded. <script> var counter = 1; function check_counter() { if(counter == 1) { alert("Please enter the product details"); return false; } document.getElementById('inv').reset(); window.open('', 'invoices', 'width=650,height=800,status=yes,resizable=yes,scrollbars=yes'); return true; } </script>
  2. No the server-side script does not populate any dynamic data in the form by name "invoice". The form by name "invoice" is just used to fill the data that is required to generate an invoice.When all the data in the form by name"invoice" is filled and clicked on a "Generate Invoice" button, an invoice(opened in new window) will be generated with data fetched from the db will be displayed in it.Meanwhile the data I filled in the form by name "invoice" will be still open in the browser tab so that by clicking again on the "Generate Invoice" button will again generate an invoice with same details in a new window. I want to clear the form by name "invoice" so that the same invoice is not reprinted again.
  3. An invoice will be opened in a new window when the Generate invoice button is clicked. Below is the sample code. For Example <form name="invoice" action="inv_rec.php" method="post" id="inv" target="invoices" onsubmit="return check_counter();" > <table> <tr> <td> <label for="cusname"><strong>Customer Name* </strong></label> <input type="text" size="20" name ="cusname" value="" id="Customername" required/> </td> <td> <label for="for_place"><strong>Place</strong></label> <input type="text" size="20" name ="for_place" value="" id="for_place" /> </td> </tr> ........ <tr> <td> <input type="submit" value="Generate Invoice" name="submit" id="sub"> </td> </tr> </table> </form> <script> var counter = 1; function check_counter() { if(counter == 1) { alert("Please enter the product details"); return false; } window.open('', 'invoices', 'width=650,height=800,status=yes,resizable=yes,scrollbars=yes'); return true; } </script> In my example the page will be redirected to inv_rec.php(opens in new window) which contains dynamically generated data obtained from mysql where the user needs to take the print of it. I want to clear all the form data which is open in the previous window(where the invoice form is displayed,i.e user fills the data to generate a invoice).Any help is appreciated.
  4. Updated code to Display tax types in select box I tried the below code. I can see the json encoded data returned from PHP file in firebug but the returned values are not visible under select box. $(function(){ $.getJSON("get_tax_type.php", function(data) { alert(data); $.each(data, function(index, item) { $("#tax_type" + counter + parseInt(index) + parseInt(1)).empty(); $("#tax_type" + counter + parseInt(index) + parseInt(1)).append("<option value='" + item.TaxID+ "'>" + item.TaxName+ "</option>"); }); }, 'json'); });
  5. I have the code that dynamically generates textboxes and select boxes upon a button click. I want to fetch the data from DB and display in the dynamically generated select box. Fiddle http://jsfiddle.net/hEByw/10/ shows how the text and selectboxes are generated dynamically. Jquery code var counter = 1; $(document).ready(function () { $("#addButton").click(function () { if(counter>7){ alert("Only 7 textboxes allow"); return false; } //To Display the tax types from DB $(function(){ var items=""; $.getJSON("get_tax_type.php",function(data){ $.each(data,function(index,item) { items+="<option value='"+item.id+"'>"+item.name+"</option>"; }); $("#tax_type' + counter + '").html(items); }); }); var newTextBoxDiv = $(document.createElement('div')) .attr("id", 'TextBoxDiv' + counter); newTextBoxDiv.after().html('<label>Product #'+ counter + ' : </label>' + '<input type="text" size="60" name="product[]"\n\ id="product' + counter + '" value="" > \n\ <label>Quantity #'+ counter + ' : </label>' + '<input type="text" size="2" name="qty[]" \n\ id="qty' + counter + '" value="" > \n\ <label>Rate #'+ counter + ' : </label>' + '<input type="text" size="2" name="rates[]"\n\ id="rates' + counter + '" value="" > \n\ <label>Tax #'+ counter + ' : </label>' + '<select id="tax_type' + counter + '" ></select> \n\ <label>Tax% #'+ counter + ' : </label>' + '<select id="tax_type' + counter + '" ></select> \n\ <label>Total #'+ counter + ' : </label>' + '<input type="text" size="3" name="total[]" id="total' + counter + '" value="" onchange="calculate();"> '); newTextBoxDiv.appendTo("#TextBoxesGroup"); counter++; }); $("#removeButton").click(function () { if(counter==0){ alert("No more textbox to remove"); return false; } counter--; $("#TextBoxDiv" + counter).remove(); }); }); HTML Code <table> <tr> <td><strong>Select the products</strong> <input type='button' value='Add Products' id='addButton'> <input type='button' value='Remove Products' id='removeButton'> </td> </tr> </table> <table> <tr> <td> <div id='TextBoxesGroup'> </div> </td> </tr> <tr> <td> <input type="hidden" id="countervalue" name="countervalue" style="display:none;"> </td> </tr> </table> PHP Code <?php include('includes/db.php'); $q = "select TaxID, TaxName from tax"; $sql = mysql_query($q); $data = array(); while($row = mysql_fetch_array($sql, true)){ $data[] = $row; }; echo json_encode($data); ?> I have tried the following part of code to fetch the data from DB and Put into dynamically generated select box but its not working for me. //To Display the tax types from DB $(function(){ var items=""; $.getJSON("get_tax_type.php",function(data){ $.each(data,function(index,item) { items+="<option value='"+item.id+"'>"+item.name+"</option>"; }); $("#tax_type' + counter + '").html(items); }); }); Can any one suggest where am I going wrong or the correct way of doing it. I am new to jquery. Any help is appreciated.Thanks in advance.
  6. I am new to php coding.I am trying to send a textbox value(invoice number) to a php file through juery and ajax.From php file I am returning the json encoded data.I want to display the Values fetched from database in the following textboxes(Total Amount,Balance Amount) and select boxes(Payment mode,Payment status). I am not getting the output I wished.Please can any one suggest me where I am going wrong.Any help is much appreciated. I have pasted my code below HTML <form name="inv_payment" method="post" action="" style="margin:0px;width:400px;"> <fieldset> <legend>Payment details</legend> <label for=inv_num>Invoice Number</label> <input id=inv_num name=inv_num type=number placeholder="12345" required autofocus > <input type=button name="get_details" id="get_details" value="Get Details" > <label for=tot_amt>Total Amount</label> <input id=tot_amt name=tot_amt type=text placeholder="12345" disabled > <br/> <label for=pay_up>Pay Up </label> <input id=pay_up name=pay_up type=text placeholder="12345" required ><br/> <label for=bal_amt>Balance Amount </label> <input id=bal_amt name=bal_amt type=text placeholder="12345" disabled > <br/> <label id="paymt_mode"><strong>Payment Mode</strong></label> <select name="pay_mode" style="width: 130px"> <option selected="selected">Cash</option> <option>Cheque</option> </select><br/> <label id="paymt_status"><strong>Payment Status</strong> </label> <select name="pay_status" style="width: 130px"> <option selected="selected">Pending</option> <option>Completed</option> </select><br/> <input type="submit" value="Payment" name="pay_btn"> </fieldset> </form> Jquery <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $('#get_details').click(function() { //To pass the invoice number and fetch related details $.getJSON("get_invpay_details.php", {id: $('#inv_num').val()}, function(data){ $('#tot_amt').val(data['Total_Amount']); $('#bal_amt').val(data['Balance_Amount']); $('#pay_mode').val(data['Payment_Type']); $('#pay_status').val(data['Payment_Status']); }); }); </script> PHP <?php include('includes/dbfunctions.php'); include('includes/db.php'); if(isset($_GET['id'])) { $tmp = $_GET['id']; $sql = mysql_query("select Total_Amount,Balance_Amount,Payment_Type,Payment_Status from invoice where InvoiceNum='$tmp'"); if(mysql_num_rows($sql)) { $data = mysql_fetch_array($sql); echo json_encode($data); } } ?>
  7. Thanks jugesh for the response. I hope you seen the jsfiddle link and the pages I have uploaded. In the code the textboxnames are generated dynamically, I mean each time the user clicks the 'Add products' button the counter value gets incremented and the id and the name gets updated with that value for example when the user clicks the 'Add Products' button the textbox names are generated automatically as name="product" + counter, name="qty" + counter, name = "rates" + counter. So I want to gather all the dynamically generated textbox values to pass to quot_rec.php and display those values. I am facing difficulty in storing the dynamically generated textbox values to php variabples. I am working on this for nearly two days.
  8. I am a newbee in php, jquery and ajax. I have a code in jquery to add and remove the textboxes dynamically on button click. I want to post the values of dynamically created textbox values to next page and display those values on action page as well as insert them into db. Any help is much appreciated. Thanks in advance. Please click on the link to see how the textboxes are dynamically created. http://jsfiddle.net/NSePb/1/ I have uploaded the two pages. I want to post the data from quotations.phpquotations.php to quot_rec.php and display the posted values on quot_rec.phpquot_rec.php
×
×
  • 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.