Jump to content

flemingmike

Members
  • Posts

    472
  • Joined

  • Last visited

Posts posted by flemingmike

  1. hi, I have a script that displays a signature of a signed work order.  here is the file that calls all the work orders

    <style>
    @page { size 8.5in 11in; }
    div.page { page-break-after: always }
    </style>
    
    
    
    <?php
    
    include 'config.php';
    
    
    $id = $_GET['id'];
    
    $result7 = mysql_query("SELECT * FROM workorders WHERE jobnumber = '$id'");
    while($row7 = mysql_fetch_array($result7))
    {
    	$woid = $row7['id'];
    	
    ?>
    <div class="page">
    
    
    
    <?php	
    include "printworkorder.php";
    ?>
    
    
    </div>	
    
    <?php
    
    }
    
    ?>
    
    
    
    
    

    then in the printworkorder.php file (which works fine with only one instance of loading it) when loading multiple work orders to print, it only signs the document on the last one. any idea how I can get it to sign all instances?

    <?php
    
    include 'config.php';
    
    if(isset($woid)){
    } else {
    $woid = $_GET['id'];
    }
    
    
    $result = mysql_query("SELECT * FROM workorders WHERE id = $woid");
    while($row = mysql_fetch_array($result))
    {
    	$wodate = $row['date'];
    	$wojobnum = $row['jobnumber'];
    	$timesheetid = $row['timesheetid'];
    	$start = $row['start'];
    	$finish = $row['finish'];
    	$timebilled = $row['timebilled'];
    	$description = $row['description'];
    	$signator = $row['signator'];
    	$signature = $row['signature'];
    	$sig_hash = $row['sig_hash'];
    	$created = $row['created'];
    	
    	}
    
    $result3 = mysql_query("SELECT * FROM timesheet WHERE id = '$timesheetid'");
    $talltime = 0;
    while($row3 = mysql_fetch_array($result3))
    {
    
      $tid=$row3['id'];
      $tdate=$row3['date'];
      $tjobnumber=$row3['jobnumber'];
      $teid=$row3['eid'];
      $tdescription=$row3['description'];
      $tsignin=$row3['start'];
      $tfinish=$row3['finish'];
      $tlunch=$row3['lunch'];
      $tschednum=$row3['schednum'];
     
      
    	
    
    $shortid=substr($tjobnumber, 5, -1); //remove the first 5 characters and minus the last character
    $jobid=substr($tjobnumber, 5); //remove the first 5 characters 
    
    $result = mysql_query("SELECT * FROM jobs WHERE id = '$shortid'");
    while($row = mysql_fetch_array($result))
    {
    $jstatus=$row['status'];
    $jaddress=$row['address']; 	
    }
    
    $mechanic = mysql_query("SELECT * FROM staff WHERE eid = '$teid'");
    while($row4 = mysql_fetch_array($mechanic))
    {
    $tmechanic=$row4['name'];
    }
    
    
      }
      
      
    $result9 = mysql_query("SELECT * FROM jobs WHERE id = '$shortid'");
    while($row9 = mysql_fetch_array($result9))
    {
    $tcustomer=$row9['customer'];
    }  
    
    
    
    ?>
    
     
      
      
    
    
    <table border="0" cellpadding="0" style="border-collapse: collapse" width="100%">
    <tr><td> </td></tr>
    <tr><td> </td></tr>
    		<tr>
    			<td valign="bottom"><div align="center">
    				<table border="0" cellpadding="2" style="border-collapse: collapse" width="100%" bordercolorlight="#000000" bordercolordark="#000000">
    					<tr>
    						<td><font face="Calibri" style="font-size:   (11 pt)">         
    						        
    						<img border="0" src="images/logo.png" ></font></td>
    						<td width="237" valign="top">
    						<p align="center">
    						<font face="Calibri" style="font-size:   (11 pt)">
    						<font size="6">Work Order</font><br><?php echo $woid ?></font></td>
    					</tr>
    				</table>
    			</div>
    			</td>
    		</tr>
    		<tr>
    			<td valign="bottom">
    			 </td>
    		</tr>
    		<tr>
    			<td valign="top">
    
    		
    			<font face="Calibri" style="font-size:   (11 pt)">
    
    		
    			<br>
    			</font>
    			<div align="center">
    				<table border="0" cellpadding="2" style="border-collapse: collapse" width="90%" bordercolorlight="#000000" bordercolordark="#000000">
    					<tr>
    						<td width="7%">
    						<i>
    						<font face="Calibri" style="font-size:   (11 pt); font-weight:700">Customer:</font></i></td>
    						<td style="border-top-style: none; border-top-width: medium" rowspan="6" valign="top" width="93%"><?php echo $tcustomer; ?></td>
    						
    					</tr>
    					<tr>
    						<td> </td>
    						</tr>
    				
    					<tr>
    						<td> </td>
    						</tr>
    					<tr>
    						<td> </td>
    						</tr>
    					<tr>
    						<td> </td>
    					</tr>
    					<tr>
    						<td colspan="2">
    						<div align="center">
    							<table border="1" cellpadding="2" style="border-collapse: collapse" width="100%" bordercolorlight="#000000" bordercolordark="#000000">
    								<tr>
    									<td align="center" valign="top"><i>
    									<font style="font-size: (11 pt); font-weight: 700" face="Calibri">
    									JOB NUMBER</font></i><br><?php echo "$jobid"; ?></td>
    									<td align="center" valign="top"><i>
    									<font style="font-size: (11 pt); font-weight: 700" face="Calibri">
    									DATE</font></i><br><?php echo date('F j, Y', $created); ?></td>
    									<td align="center" valign="top" colspan="2"><i>
    									<font style="font-size: (11 pt); font-weight: 700" face="Calibri">
    									ADDRESS</font></i><br><?php echo "$jaddress"; ?></td>
    									
    								</tr>
    					<tr>
    						<td colspan="4" ></td>
    					</tr>
    					
    					
    					
    								<tr>
    									<td align="center" valign="top"><i>
    									<font style="font-size: (11 pt); font-weight: 700" face="Calibri">
    									TECHNICIAN</font></i><br><?php echo "$tmechanic"; ?></td>
    									<td align="center" valign="top"><i>
    									<font style="font-size: (11 pt); font-weight: 700" face="Calibri">
    									TIME IN</font></i><br><?php echo "$start"; ?></td>
    									<td align="center" valign="top"><i>
    									<font style="font-size: (11 pt); font-weight: 700" face="Calibri">
    									TIME OUT</font></i><br><?php echo "$finish"; ?></td>
    									<td align="center" valign="top"><i>
    									<font style="font-size: (11 pt); font-weight: 700" face="Calibri">
    									TIME BILLED</font></i><br><?php echo "$timebilled hours"; ?></td>
    								</tr>
    								<tr>
    								<td colspan="4">
    								<font face="Calibri" style="font-size:   (11 pt)">
    						<i><b>Description Of Work: </b></i></font>
    						<br>
    						<tt><font face="Arial"><?php echo $description; ?></font><br><br>
    								</td>
    								</tr>
    								
    								
    								
    								
    								</table>
    						</div>
    						</td>
    					</tr>
    					
    					
    					
    				</table>
    			</div>
    			</td>
    		</tr>
    		<tr>
    			<td valign="bottom">
    			<div align="center">
    				<table border="0" cellpadding="2" style="border-collapse: collapse" width="90%" bordercolorlight="#000000" bordercolordark="#000000">
    					
    					<tr>
    						<td style="border-top-style: none; border-top-width: medium"> </td>
    						<td width="175" style="border-top-style: none; border-top-width: medium"> </td>
    					</tr>
    					<tr>
    					<td>
    					<br><br><br>
    						Date Signed: <?php echo date('F j, Y g:i A', $created); ?><br><br>
    						
    						Printed Name: <?php echo htmlentities($signator, ENT_NOQUOTES, 'UTF-8'); ?><br><br>
    						
    						Signature: 
    <?php //regenerate signature ?>
    <div class="sigPad signed">
      <div class="sigWrapper">
      <div class="typed">
     <?php echo htmlentities($signator, ENT_NOQUOTES, 'UTF-8'); ?>
      </div>
      <canvas class="pad" width="348" height="120"></canvas>
      </div>
      <br>
    </div>
    					
    					
    					
    
    <script src="mobile/signature-pad/build/jquery.min.js"></script>
    
    <script src="mobile/signature-pad/build/jquery.signaturepad.min.js"></script>
    
    <script>
        $(document).ready(function () {
    	  // Write out the complete signature from the database to Javascript
          var sig = <?php echo $signature; ?>;
          $('.sigPad').signaturePad({displayOnly : true}).regenerate(sig);
        });
    </script>
    <?php //regenerate signature ?>
    
    <br><br>
    					
    					</td>
    					</tr>
    				</table>
    			</div>
    			</td>
    		</tr>
    		<tr>
    			<td valign="bottom">
    			<div align="center">
    			<div align="center">
    				<table border="0" cellpadding="2" style="border-collapse: collapse" width="90%" bordercolorlight="#000000" bordercolordark="#000000">
    					<tr>
    						<td width="33%">
    						<font face="Calibri" style="font-size:   (11 pt)" size="2">Phone: 
    						905-420-2043</font></td>
    						<td width="33%">
    						<p align="center">
    						<font face="Calibri" style="font-size:   (11 pt)" size="2">817 Brock Road, Unit 
    						#7<br>Pickering, Ontario, L1W 3L9</font></td>
    						<td width="33%">
    						<p align="right">
    						<font face="Calibri" style="font-size:   (11 pt)" size="2">Fax: 905-420-5040</font>
    						</td>
    					</tr>
    				</table>
    			</div>
    								
    			</div>
    			</td>
    		</tr>
    		</table>
    </div>	
    
    
    
    
    
    
    

    any help is appreciated

  2. ive narrowed it down to an issue with the foreach.  its using the foreach count for the existing first then the newly added. I need to have it as 2 separate for each counts but not sure how I can because I need all the fields to be consistently named ie. name='ltotal[]' for the math that happens on the page.

  3. if(isset($_POST['lqlabour']))
    {
    //insert quoted labour
    foreach ($_POST['lqlabour'] as $k => $lqlabour) {
        $ldescription = $_POST['ldescription'][$k];
    	$llabour = $_POST['llabour'][$k];
    	$lhelper = $_POST['lhelper'][$k];
    	$lmarkup = $_POST['lmarkup'][$k];
    	$ltotal = $_POST['ltotal'][$k];
    	
    	
    	
    	if ($ltotal == '0.00'){
    	 $lstatus = "2";
    	 } else {
    	 $lstatus = "1";
    	 }
    	
    	 $sql = "INSERT INTO quotedlabour VALUES (
    	 NULL, 
    	 $quoteid,
    	 $k,
    	 '" . mysql_real_escape_string($lqlabour) ."',
    	 '" . mysql_real_escape_string($ldescription) ."',
    	 '" . mysql_real_escape_string($llabour) ."',
    	 '" . mysql_real_escape_string($lhelper) ."',
    	 '" . mysql_real_escape_string($lmarkup) ."',
    	 '" . mysql_real_escape_string($ltotal) ."',
    	 '" . mysql_real_escape_string($lstatus) ."'
    	 )";
    	 mysql_query($sql) or die('Error 33 adding.  Check you fields and try again.');	 
    }
    }
    //insert quoted labour
    
    
    
    
    //update existing labour status
    foreach ($_POST['lid'] as $s => $lid) {
    $lid = $_POST['lid'][$s];
    $ltotal = $_POST['ltotal'][$s];
    
    
    if ($ltotal == '0.00'){
    	 $lstatus = "2";
    	 } else {
    	 $lstatus = "1";
    	 }
    
    $sql1 = "UPDATE quotedlabour SET status = '" . mysql_real_escape_string($lstatus) ."', total = '" . mysql_real_escape_string($ltotal) ."' WHERE id = '$lid'"; 
      
    $result3 = mysql_query($sql1) or die('Error, updating 222 failed.  Check you fields and try again.');
    
    }
    //update existing labour status
    
    
    
    
    $lii=200;		
    $result = mysql_query("SELECT * FROM quotedlabour WHERE quoteid = $quoteid ORDER BY linenumber");
    while($row = mysql_fetch_array($result))
    {
    
      $id=$row['id'];
      $qlabour=$row['qlabour'];
      $description=$row['description'];
      $labour=$row['labour'];
      $helper=$row['helper'];
      $markup=$row['markup'];
      $total=$row['total'];
      $status=$row['status'];
      
      if($status == 1) {     
        $active = "checked";
    }
      if($status == 2) {     
        $active = "unchecked";
    	}
     
    $lqty="lqlabour-$lii";
    $lqhelper="lhelper-$lii";
    $lqlabour="llabour-$lii";
    $lqtotal="ltotal-$lii";
    $lqbox="lbox-$lii";
      
    
      echo "<tr>";
      echo "<input type='hidden' name='lid[]' value='" . $id . "'>";
      echo "<td align='center'><input type='text' name='lqlabour[]' id='" . $lqty . "' size='10' disabled='disabled' value='" . $qlabour . "'></td>";
      echo "<td align='center'>" . $description . "</td>";
      echo "<td align='center'><input type='text' name='llabour[]' id='" . $lqlabour . "' size='10' disabled='disabled' value='" . $labour . "'></td>";
      echo "<td align='center'><input type='text' name='lhelper[]' id='" . $lqhelper . "' size='10' disabled='disabled' value='" . $helper . "'></td>";
      echo "<td align='center'><input type='text' name='ltotal[]' id='" . $lqtotal . "' size='10' readonly value='" . $total . "'></td>";
      echo "<td align='center'><input type='checkbox' name='lbox[]' id='" . $lqbox . "' value='0' $active onblur='filllabour(this.id)'></td>";
      echo "</tr>";
      
      $lii=$lii+1;
      }
    		
    

    Hi All, I have the following code which is a form that pulls records from a database to show and it also allows you to dynamically add new rows to the database and im stumped.  when I submit a form the record that previously existed is updated perfectly but any time I add a new record it is adding it but one field called total is getting its value from the first row of the database instead of using the data from the form.  any help is much appreciated.

     

     

  4. 
    <script>
    //Calculate Labour
        function filllabour(aa) {
    	
    	//Parse aa
    	
    	var the_string = aa;
    	var parts = the_string.split('-', 2);
    
    		// After calling split(), 'parts' is an array with two elements:
    		// parts[0] is 'left or -'
    		// parts[1] is 'right of -'
    
    	var the_text = parts[0];
    	var the_num  = parts[1];
    	
    	//Parse aa
    
    	var dblQuantity = document.getElementById('lqlabour-' + the_num).value-0;
    	var curRate = document.getElementById("llabour-" + the_num).value-0;
    	var curRateHelper = document.getElementById("lhelper-" + the_num).value-0;
    	var dblMarkup = document.getElementById("lmarkup-" + the_num).value-0;
    	var curTotal = parseFloat(dblMarkup) / 100.0;
    	llinetotal = ((dblQuantity * curRate) + (dblQuantity * curRateHelper)) * (1 + curTotal);
    	llinetotal = llinetotal.toFixed(2);
        document.getElementById("ltotal-" + the_num).value = llinetotal;
    	//document.getElementById(the_num).value = ("test");
    	//alert(the_num);
    	
    	
    	//collect all line totals	
    	var inputs = document.getElementsByName("ltotal[]");
    	var laboursubtotal = 0;
    
    	for (var i = 0.00; i < inputs.length; i++){
    		if (inputs[i].type = "text"){
    			laboursubtotal += parseFloat(inputs[i].value, 10);
    		}
    	}
    	//collect all line totals
    	laboursubtotal = laboursubtotal.toFixed(2);
    	document.getElementById("labourtotal").value = laboursubtotal;
    	
    		
    	filltotal();
    	
    	
        }
    //Calculate Labour
    </script>

    hi, in ie11 we are forced to use compatibility mode for one of our web applications written in php.  above is a script that from what I understand is the error is with getElementsByName.  any suggestions for me in ie11?

     

  5. hi, how can i collect all the vaues of all the ltotal text boxes created and add them together?

      var column5 = row_in_table.insertCell(5);
    			column5.setAttribute("align", "center"); 
                var element5 = document.createElement("input");
    
                element5.setAttribute("name", "ltotal[]");
    			element5.setAttribute("id", "ltotal" + '-' + i);
    			element5.setAttribute("value", ""); 
    			element5.setAttribute("size", "7"); 
    			element5.type = "text";
    			element5.setAttribute('onblur','filllabour(this.id)');
    
               column5.appendChild(element5);			
    
    //counter + 1           
    		   i += 1;
    
            }
    
    
    
    // End Of Labour Table
    </script>
    
    
    
    
    <script>
    //Calculate Labour
        function filllabour(aa) {
    	
    	//Parse aa
    	
    	var the_string = aa;
    	var parts = the_string.split('-', 2);
    
    		// After calling split(), 'parts' is an array with two elements:
    		// parts[0] is 'left or -'
    		// parts[1] is 'right of -'
    
    	var the_text = parts[0];
    	var the_num  = parts[1];
    	
    	//Parse aa
    
    	var dblQuantity = document.getElementById('lqlabour-' + the_num).value-0;
    	var curRate = document.getElementById("llabour-" + the_num).value-0;
    	var curRateHelper = document.getElementById("lhelper-" + the_num).value-0;
    	var dblMarkup = document.getElementById("lmarkup-" + the_num).value-0;
    	var curTotal = parseFloat(dblMarkup) / 100.0;
    	llinetotal = ((dblQuantity * curRate) + (dblQuantity * curRateHelper)) * (1 + curTotal);
    	llinetotal = llinetotal.toFixed(2);
        document.getElementById("ltotal-" + the_num).value = llinetotal;
    	//document.getElementById(the_num).value = ("test");
    	//alert(the_num);
    	
    	document.getElementById("labourtotal").value = aa;
    	
        }
    //Calculate Labour
    </script>
    
  6. its not populating the total text box.  here is the filllabour

    <script>
    //Calculate Labour
        function filllabour() {
    	
            var txt6 = document.getElementsByName("lqlabour[]").value-0;
    		var txt7 = document.getElementsByName("llabour[]").value-0;
    		var txt8 = document.getElementsByName("lhelper[]").value-0;
            var markup = document.getElementsByName("lmarkup[]").value-0;
    		var muresult = parseFloat(markup) / 100.0;
            document.getElementsByName("ltotal[]").value = ((txt6 * txt7) + (txt6 * txt8)) * (1 + muresult);
    	
    	
    
        }
    //Calculate Labour
    </script>
    

    here is my dynamic add

     //to insert the sixth column (for textbox to accept age)
                var column5 = row_in_table.insertCell(5);
    			column5.setAttribute("align", "center"); 
                var element5 = document.createElement("input");
    
                element5.setAttribute("name", "ltotal[]");
    			element5.setAttribute("id", "ltotal");
    			element5.setAttribute("value", ""); 
    			element5.setAttribute("size", "7"); 
    			element5.type = "text";
    			element5.onchange = filllabour;
    
                column5.appendChild(element5);		
    
  7. here is something else im trying with no luck

     //to insert the sixth column (for textbox to accept age)
                var column5 = row_in_table.insertCell(5);
    			column5.setAttribute("align", "center"); 
                var element5 = document.createElement("input");
    
                element5.setAttribute("name", "ltotal[]");
    			element5.setAttribute("id", "ltotal");
    			element5.setAttribute("value", ""); 
    			element5.setAttribute("size", "7"); 
    			element5.type = "text";
    			element5.onclick = function(filllabour)
    				{
    					alert("Changed!");
    				}
    
                column5.appendChild(element5);			
    	
               
    
            }
    
    
    
    // End Of Labour Table
    </script>
    
    
    
    
    <script>
    //Calculate Labour
        function filllabour() {
            var txt6 = document.getElementsByName("lqLabour[]").value-0;
    		var txt7 = document.getElementsByName("llabour[]").value-0;
    		var txt8 = document.getElementsByName("lhelper[]").value-0;
            var markup = document.getElementsByName("lmarkup[]").value-0;
    		var muresult = parseFloat(markup) / 100.0;
            document.getElementsByName("ltotal[]").value = ((txt6 * txt7) + (txt6 * txt8)) * (1 + muresult);
    
    
        }
    //Calculate Labour
    </script>
    
  8. hello, anyone able to help me with why the following may not be working?

    element6.setAttribute("onchange", "filllabour()"); 
    

    

     

     

    here is my filllabour

    <script>
    //Calculate Labour
        function filllabour() {
            var txt6 = document.getElementsByName("lqLabour[]").value-0;
    		var txt7 = document.getElementsByName("llabour[]").value-0;
    		var txt8 = document.getElementsByName("lhelper[]").value-0;
            var markup = document.getElementsByName("lmarkup[]").value-0;
    		var muresult = parseFloat(markup) / 100.0;
            document.getElementsByName("ltotal[]").value = ((txt6 * txt7) + (txt6 * txt8)) * (1 + muresult);
    
    
        }
    //Calculate Labour
    </script>
    

    here is my full insert column

                var column6 = row_in_table.insertCell(4);
    			column6.setAttribute("align", "center"); 
                var element6 = document.createElement("input");
    
                element6.setAttribute("name", "lmarkup[]");  //to set name of the text box
    			element6.setAttribute("id", "lmarkup");
    			element6.setAttribute("value", "30"); 
    			element6.setAttribute("size", "7"); 
    			element6.setAttribute("onchange", "filllabour()"); 
    			element6.type = "text";
    
                column6.appendChild(element6);	
    

    

  9. hello, I don't know how I screwed it up but I did! the following code will only add the first entry of the foreach. 

     

    Form:

    		<tr>
    			<td valign="bottom">
    			<div align="center">
    				<table border="1" cellpadding="2" style="border-collapse: collapse" width="90%" bordercolorlight="#000000" bordercolordark="#000000">
    
    					<tr>
    						<td align="center" width="11%"><b>Q Labour</b></td>
    						<td align="center" width="43%"><b>Description</b></td>
    						<td align="center" width="13%"><b>Labour</b></td>
    						<td align="center" width="12%"><b>Helper</b></td>
    						<td align="center" width="19%"><b>Labour Markup</b></td>
    					</tr>
    					<tr>
    						<td align='center' width='11%'>
    						<input type='text' name='lqlabour[]' size='4'></td>
    						<td align='center' width='43%'>
    						<textarea rows='2' name='ldescription[]' cols='30'></textarea></td>
    						<td align='center' width='13%'>
    						<input type='text' name='llabour[]' size='7'></td>
    						<td align='center' width='12%'>
    						<input type='text' name='lhelper[]' size='7'></td>
    						<td align='center' width='19%'>
    						<input type='text' name='lmarkup[]' size='7' value='30%'></td>
    					</tr>
    					</table>
    				<table border="1" cellpadding="2" style="border-collapse: collapse" width="90%" bordercolorlight="#000000" bordercolordark="#000000">					
    					<tr>
    					<div id="dynamicInput1">
    					
    					</div>					
    					</tr>
    					<tr>
    						<td colspan="5">
    						<input type="button" value="Add Line" onClick="addLabour('dynamicInput1');" style="float: right"></td>
    					</tr>
    					<tr>
    						<td colspan="5">
    						<p align="right"> </td>
    					</tr>
    
    				</table>
    			</div>
    			</td>
    		</tr>
    

    post.php

    <?php
    include '../config.php';
    
    
    
    foreach ($_POST['lqlabour'] as $k => $lqlabour) {
        $ldescription = $_POST['ldescription'][$k];
    	$llabour = $_POST['llabour'][$k];
    	$lhelper = $_POST['lhelper'][$k];
    	$lmarkup = $_POST['lmarkup'][$k];
    
    
    	
    	 $sql = "INSERT INTO test VALUES (
    	 NULL, 
    	 '" . mysql_real_escape_string($lqlabour) ."',
    	 '" . mysql_real_escape_string($ldescription) ."',
    	 '" . mysql_real_escape_string($llabour) ."',
    	 '" . mysql_real_escape_string($lhelper) ."',
    	 '" . mysql_real_escape_string($lmarkup) ."'
    	 )";
    	 mysql_query($sql) or die('Error adding.  Check you fields and try again.');
    	 
    	 
         echo $lqlabour . $ldescription . $llabour . $lhelper . $lmarkup . "<br>";
    }
    
    
    
    
    
    ?>
    
    
    
    
    
    

    javascript:

    var counter = 1;
    var limit = 3;
    function addLabour(divName){
         if (counter == limit)  {
              alert("You have reached the limit of adding " + counter + " inputs");
         }
         else {
              var newdiv = document.createElement('div');
              newdiv.innerHTML = " <table border='1' cellpadding='2' style='border-collapse: collapse' width='90%' bordercolorlight='#000000' bordercolordark='#000000'>  <tr> <td align='center' width='11%'> <input type='text' name='lqlabour[]' size='4'></td> <td align='center' width='43%'> <textarea rows='2' name='ldescription[]' cols='30'></textarea></td> <td align='center' width='13%'> <input type='text' name='llabour[]' size='7'></td> <td align='center' width='12%'> <input type='text' name='lhelper[]' size='7'></td> <td align='center' width='19%'> <input type='text' name='lmarkup[]' size='7' value='30%'></td> </tr>  </table>";
              document.getElementById(divName).appendChild(newdiv);
              counter++;
         }
    }
    
    
  10. hello, im trying to create a form with being able to dynamically add another row to the form on the fly.  below is the form code I am using as well as the javascript to add the next row.  I feel like it may be as simple as moving the div line.  any help is appreciated!

    <div align="center">
    				<table border="1" cellpadding="2" style="border-collapse: collapse" width="90%" bordercolorlight="#000000" bordercolordark="#000000">
    
    					<tr>
    						<td align="center" width="11%"><b>Q Labour</b></td>
    						<td align="center" width="43%"><b>Description</b></td>
    						<td align="center" width="13%"><b>Labour</b></td>
    						<td align="center" width="12%"><b>Helper</b></td>
    						<td align="center" width="19%"><b>Labour Markup</b></td>
    					</tr>
    					<tr>
    						<td align="center" width="11%">
    						<input type="text" name="lqlabour[]" size="4"></td>
    						<td align="center" width="43%">
    						<textarea rows="2" name="ldescription[]" cols="30"></textarea></td>
    						<td align="center" width="13%">
    						<input type="text" name="llabour[]" size="7"></td>
    						<td align="center" width="12%">
    						<input type="text" name="lhelper[]" size="7"></td>
    						<td align="center" width="19%">
    						<input type="text" name="lmarkup[]" size="7" value="30%"></td>
    					</tr>
    					<tr>
    						<td align="center" width="11%">
    						<input type="text" name="lqlabour[]" size="4"></td>
    						<td align="center" width="43%">
    						<textarea rows="2" name="ldescription[]" cols="30"></textarea></td>
    						<td align="center" width="13%">
    						<input type="text" name="llabour[]" size="7"></td>
    						<td align="center" width="12%">
    						<input type="text" name="lhelper[]" size="7"></td>
    						<td align="center" width="19%">
    						<input type="text" name="lmarkup[]" size="7" value="30%"></td>
    					</tr>					
    					<tr>
    					<div id="dynamicInput">
    					</tr>
    					<tr>
    						<td colspan="5">
    						<input type="button" value="Add Line" onClick="addLabour('dynamicInput');" style="float: right"></td>
    					</tr>
    					<tr>
    						<td colspan="5">
    						<p align="right"> </td>
    					</tr>
    					</div>
    				</table>
    			</div>
    
    var counter = 1;
    var limit = 3;
    function addLabour(divName){
         if (counter == limit)  {
              alert("You have reached the limit of adding " + counter + " inputs");
         }
         else {
              var newdiv = document.createElement('div');
              newdiv.innerHTML = " <tr>" + "<td align='center' width='11%'>" + "<input type='text' name='lqlabour[]' size='4'></td>" + "<td align='center' width='43%'>" + "<textarea rows='2' name='ldescription[]' cols='30'></textarea></td>" + "<td align='center' width='13%'>" + "<input type='text' name='llabour[]' size='7'></td>" + "<td align='center' width='12%'>" + "<input type='text' name='lhelper[]' size='7'></td>" + "<td align='center' width='19%'>" + "<input type='text' name='lmarkup[]' size='7' value='30%'></td>" + "</tr> ";
              document.getElementById(divName).appendChild(newdiv);
              counter++;
         }
    }
    
    
  11. So if I wanted to submit it as 3 fields and the third being r, would I do it as below?

    foreach ($_POST['d'] as $k => $d) {
        $q = $_POST['q'][$k];
        $r = $_POST['r'][$k];
        // insert $d and $q into db table
    }
    
  12. form:

    <script src="addInput.js" language="Javascript" type="text/javascript"></script>
    <form method="POST" action="post.php">
         <div id="dynamicInput">
              Entry 1<br><input type='text' name='d[]'> <input type='text' name='q[]'>
         </div>
         <input type="button" value="Add another text input" onClick="addInput('dynamicInput');">
    	 <input type="submit" value="Submit" name="submit">
    </form>
    
    

    javascripts:

    var counter = 1;
    var limit = 6;
    function addInput(divName){
         if (counter == limit)  {
              alert("You have reached the limit of adding " + counter + " inputs");
         }
         else {
              var newdiv = document.createElement('div');
              newdiv.innerHTML = "Entry " + (counter + 1) + " <br><input type='text' name='d[]'> <input type='text' name='q[]'>";
              document.getElementById(divName).appendChild(newdiv);
              counter++;
         }
    }
    
    

    Once I get this test working my full version form will have 8 txt boxes for each "Add Another"

  13. hello, im submitting a form that has 2 text fields.  im using javascript to add in another 2 fields if needed.  im not sure how to use a foreach to get both field twice.  here is my code below

    $myInputsd = $_POST["d"];
    $myInputsq = $_POST["q"];
    foreach ($myInputsd as $eachInputd) {
    foreach ($myInputsq as $eachInputq) {
    
    
    	 $sql = "INSERT INTO test VALUES (
    	 NULL, 
    	 $eachInputd,
    	 $eachInputq
    	 )";
    	 mysql_query($sql) or die('Error adding.  Check you fields and try again.');
    	 
    	 
         echo $eachInputd . $eachInputq . "<br>";
    }
    }
    
    
    
  14. hi, im trying to create a date array based on the results of a query.  here is what i have

     

    $query = "SELECT * FROM holidays"; 
    $result = mysql_query($query) or die(mysql_error());
    while($row = mysql_fetch_array($result)){
    $holidays=$row['date'];		
    }
    
    

     

    im trying to get this to look something like this after i exit the }

     

    $holidays=array("2012-12-25","2012-12-26","2013-01-01"); 

     

    thanks!

  15. nevermind.  this isnt my problem.

     

    ime getting an error

    Notice: Undefined variable: import in E:\Website\hockeypool\admin\import.php on line 31
    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INSERT into goaliestats(id,name,gp,w,so,gaa,date) values(NULL,'Carey Price','72'' at line 2

     

    this is the line thats having the error:

     

    Carey Price,VAN,72,,60,,3590,,38,,15,,7,,3,,126,,2.11,,1753,,1627,,0.928,,4,,9/29/2011

     

    any ideas on this?

  16. hi, i have a script that inserts a csv into mysql.  i run into errors when there is an empty field

     

    example:

     

    filed1,field2,field3,,field5,,field7

     

    here is my code that processes it.

     

    	$handle = fopen("uploads/$filename", "r");	
    
    while(($data = fgetcsv($handle, 1000, ",")) !== FALSE)      {
    
    
    
    $import .= "INSERT into goaliestats(id,name,gp,w,so,gaa,date) values(NULL,'$data[0]','$data[2]','$data[8]','$data[26]','$data[18]','$data[28]')" . "\n";
    
    mysql_query($import) or die(mysql_error());
    }
    
    
    fclose($handle);

     

     

    is there a way i can make a ,, into ,0,

     

    ?

     

    thanks!

  17. ok, so i removed the part about $x and i now get just the first record to insert.  here is my error:

     

    Notice: Undefined variable: import in E:\Website\hockeypool\admin\import.php on line 29
    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INSERT into goaliestats(id,name,gp,w,so,gaa,date) values(NULL,'Carey Price','72'' at line 2

     

    here is my code mod

     

    	$handle = fopen("uploads/$filename", "r");	
    
    while(($data = fgetcsv($handle, 1000, ",")) !== FALSE)      {
    
    $import .= "INSERT into goaliestats(id,name,gp,w,so,gaa,date) values(NULL,'$data[0]','$data[2]','$data[8]','$data[26]','$data[18]','$data[28]')" . "\n";
    $x++;
    
    mysql_query($import) or die(mysql_error());
    }
    
    
    fclose($handle);

×
×
  • 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.