Jump to content

Easy Reset Total Question


j1steve

Recommended Posts

Alright, I'm using the following code to calculate a price for a wedding photography package.  The only problem is, the reset button does reset all of the drop down options, but not the calculated total.  Any advice?

 <script type="text/javascript">
function resetvalue(){
    document.getElementById('result_ans').innerHTML = ['val'][0],700';
    return true;
}
</script>
<?php 
if (isset($_POST['submit']))
{
$added_cost =  array_sum($_POST['val']);
$total_cost = 1700 + $added_cost;
$total =  number_format($total_cost, 0);
}
else $total = '1,700';

?>

   <div align="center" id="form"> 

<form method= "post" action="">




<p>Wedding Day Coverage:
<select name="val[]" class="text">  
  <option value="0" selected>6 Hours (included)</option>
<option value="200" <?php echo $_POST['val'][0]==200 ? 'selected' : '' ?>>7 Hours (+ 200)</option>
<option value="500" <?php echo $_POST['val'][0]==500 ? 'selected' : '' ?>>8 Hours (+ 500)</option>
<option value="800" <?php echo $_POST['val'][0]==900 ? 'selected' : '' ?>>9 Hours (+ 800)</option>
<option value="1100" <?php echo $_POST['val'][0]==1100 ? 'selected' : '' ?>>10 Hours (+ 1100)</option>
<option value="1400" <?php echo $_POST['val'][0]==1400 ? 'selected' : '' ?>>11 Hours (+ 1400)</option>
<option value="1700" <?php echo $_POST['val'][0]==1700 ? 'selected' : '' ?>>12 Hours (+ 1700)</option>

</select>
</p>

<p>Rehearsal Dinner Coverage:
<select name="val[]" class="text">
  <option value="0" selected>no coverage</option>
<option value="400" <?php echo $_POST['val'][1]==400 ? 'selected' : '' ?> >2 Hours (+ 400)</option>
<option value="600" <?php echo $_POST['val'][1]==600 ? 'selected' : '' ?> >4 Hours (+ 600)</option>
<option value="800" <?php echo $_POST['val'][1]==800 ? 'selected' : '' ?> >6 Hours (+ 800)</option>

</select>
</p>

<p>Engagement Photo Session:
<select name="val[]" class="text">
  <option value="0" selected>no engagement photo session</option>
<option value="200" <?php echo $_POST['val'][2]==200 ? 'selected' : '' ?>>engagement photo session (+ $200)</option>
</select>
</p>

<p>Travel (excludes destination weddings):
<select name="val[]" class="text">
  <option value="0" selected>travel within 20 miles ($0)</option>
<option value="50" <?php echo $_POST['val'][3]==50 ? 'selected' : '' ?> >1 hours each way (+ $50)</option>
<option value="100" <?php echo $_POST['val'][3]==100 ? 'selected' : '' ?> >2 hours each way (+ $100)</option>
<option value="150" <?php echo $_POST['val'][3]==150 ? 'selected' : '' ?> >3 hours each way (+ $150)</option>
<option value="200" <?php echo $_POST['val'][3]==200 ? 'selected' : '' ?> >4 hours each way (+ $200)</option>
</select></p>

<p>Wedding album:
<select name="val[]" class="text">
  <option value="0" selected>no album</option>

<option value="450" <?php echo $_POST['val'][4]==450 ? 'selected' : '' ?> >AsukaBook BookBound 10x10 (up to 120 photos) (+ $450)</option>
<option value="500" <?php echo $_POST['val'][4]==500 ? 'selected' : '' ?> >AsukaBook BookBound EX 10x10 (up to 120 photos) (+ $500)</option>
<option value="850" <?php echo $_POST['val'][4]==850 ? 'selected' : '' ?> >8x10 Sequoia (45 images) (+ $850)</option>
<option value="950" <?php echo $_POST['val'][4]==950 ? 'selected' : '' ?> >10x10 Sequoia (45 images) (+ $950)</option>
<option value="1050" <?php echo $_POST['val'][4]==1050 ? 'selected' : '' ?> >10x15 Sequoia (45 images) (+ $1050)</option>
<option value="675" <?php echo $_POST['val'][4]==675 ? 'selected' : '' ?> >8x10 Cypress "C" (75 images) (+ $675)</option>
<option value="750" <?php echo $_POST['val'][4]==750 ? 'selected' : '' ?> >9x12 Cypress "C" (75 images) (+ $750)</option>
<option value="825" <?php echo $_POST['val'][4]==825 ? 'selected' : '' ?> >11x11 Cypress "C" (75 images) (+ $825)</option>
<option value="900" <?php echo $_POST['val'][4]==900 ? 'selected' : '' ?>>13x13 Cypress "C" (75 images) (+ $900)</option>
<option value="1200" <?php echo $_POST['val'][4]==1200 ? 'selected' : '' ?>>8x8 Cypress (45 images) (+ $1200)</option>
<option value="1350" <?php echo $_POST['val'][4]==1350 ? 'selected' : '' ?>>10x10 Cypress (45 images) (+ $1350)</option>
<option value="1600" <?php echo $_POST['val'][4]==1600 ? 'selected' : '' ?>>12x12 Cypress (45 images) (+ $1600)</option>
</select>
</p>

<p>Additional Wedding Album:
<select name="val[]" class="text">
  <option value="0" selected>no album</option>
<option value="450" <?php echo $_POST['val'][5]==450 ? 'selected' : '' ?>>AsukaBook BookBound 10x10 (up to 120 photos) (+ $450)</option>
<option value="500" <?php echo $_POST['val'][5]==500 ? 'selected' : '' ?>>AsukaBook BookBound EX 10x10 (up to 120 photos) (+ $500)</option>
<option value="850" <?php echo $_POST['val'][5]==850 ? 'selected' : '' ?>>8x10 Sequoia (45 images) (+ $850)</option>
<option value="950" <?php echo $_POST['val'][5]==950 ? 'selected' : '' ?>>10x10 Sequoia (45 images) (+ $950)</option>
<option value="1050" <?php echo $_POST['val'][5]==1050 ? 'selected' : '' ?>>10x15 Sequoia (45 images) (+ $1050)</option>
<option value="675" <?php echo $_POST['val'][5]==675 ? 'selected' : '' ?> >8x10 Cypress "C" (75 images) (+ $675)</option>
<option value="750" <?php echo $_POST['val'][5]==750 ? 'selected' : '' ?> >9x12 Cypress "C" (75 images) (+ $750)</option>
<option value="825" <?php echo $_POST['val'][5]==825 ? 'selected' : '' ?> >11x11 Cypress "C" (75 images) (+ $825)</option>
<option value="900" <?php echo $_POST['val'][5]==900 ? 'selected' : '' ?>>13x13 Cypress "C" (75 images) (+ $900)</option>
<option value="1200" <?php echo $_POST['val'][5]==1200 ? 'selected' : '' ?>>8x8 Cypress (45 images) (+ $1200)</option>
<option value="1350" <?php echo $_POST['val'][5]==1350 ? 'selected' : '' ?>>10x10 Cypress (45 images) (+ $1350)</option>
<option value="1600" <?php echo $_POST['val'][5]==1600 ? 'selected' : '' ?>>12x12 Cypress (45 images) (+ $1600)</option>
</select>
</p>


<p>Archival Print Prices:</p><table align="center" cellpadding="5" cellspacing="0" bgcolor="#333333">
<tr>
	<td>4x6"  -$4</td>
	<td>5x7"  -$6</td>
	<td>6x8"  -$6</td>
	<td>8x10"  -$15</td>
</tr>
<tr>
	<td>10x15"  -$20</td>
	<td>12x18"  -$40</td>
	<td>11x14"  -$30</td>
	<td>16x20"  -$60</td>
</tr>
</table>
<p>Professional Print Credit: $<input type="text" name="val[]" size="10" value= ></p>

<p>Proofing/Digital or Film Negatives:
<select name="val[]" class="text">
  <option value="0" selected>full set of digital negatives (included)</option>
<option value="300" <?php echo $_POST['val'][6]==300 ? 'selected' : '' ?> >silk or leather proof book(+ $300)</option>
<option value="425" <?php echo $_POST['val'][6]==425 ? 'selected' : '' ?>>complete set of 3.5x5" proofs (+ $425)</option>
</select>
</p>

<p><input type="submit" name="submit" value="Calculate" style="background-color: white; cursor: pointer; padding: 5px; border: 1px solid #333;">
<span class="result_txt">Estimated wedding amount: $ <span class="result_ans" id="result_ans"><?php echo $total ?></span></span>
<input type="reset" name="Reset" value="Reset" onClick="resetvalue()" style="background-color: white; cursor: pointer; margin: 0 0 0 15px;">
</p>
  <p style="color:#CC0000;">
  </p>
  
  
  </form></div>

 

 

Link to comment
https://forums.phpfreaks.com/topic/122906-easy-reset-total-question/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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