Jump to content

Tricky for Me - Easy For You!? Perhaps?


j1steve

Recommended Posts

Hello,

        So despite having taken an online php class, which was a while ago, I cannot for the life of me figure out how to add up these drop down menu options so that they appear in the total box at the bottom.  I want the default value in the total box to be $1700, and each additional item selected is add on to that.  Any help would be much appreciated.  Here is the page code and yes, I know its not perfect:

 

<form method="post" action="calculate.php">
<p>Second Photographer:
<select name="val1" class="text">
  <option value="0" selected>no second photographer</option>
<option value="200" >2 hours (+ $200)</option>
<option value="300" >3 hours (+ $300)</option>
<option value="400" >4 hours (+ $400)</option>
<option value="500" >5 hours (+ $500)</option>
<option value="600" >6 hours (+ $600)</option>
<option value="700" >7 hours (+ $700)</option>
<option value="800" >8 hours (+ $800)</option>
</select>
</p>

<p>Wedding Day Coverage:
<select name="val2" class="text">  
  <option value="0" selected>6 Hours (included)</option>
<option value="300" >7 Hours (+ 300)</option>
<option value="600" >8 Hours (+ 600)</option>
<option value="900" >9 Hours (+ 900)</option>
<option value="1200" >10 Hours (+ 1200)</option>
<option value="1500" >11 Hours (+ 1500)</option>
<option value="1800" >12 Hours (+ 1800)</option>

</select>
</p>

<p>Rehearsal Dinner Coverage:
<select name="val3" class="text">
  <option value="0" selected>no coverage</option>
<option value="600" >2 Hours (+ 600)</option>
<option value="900" >4 Hours (+ 900)</option>
<option value="1200" >6 Hours (+ 1200)</option>

</select>
</p>

<p>Engagement Photo Session:
<select name="val4" class="text">
  <option value="0" selected>no engagement photo session</option>
<option value="300" >engagement photo session (+ $300)</option>
</select>
</p>

<p>Travel (excludes destination weddings):
<select name="val5" class="text">
  <option value="0" selected>travel within 20 miles ($0)</option>
<option value="100" >1 hours each way (+ $100)</option>
<option value="200" >2 hours each way (+ $200)</option>
<option value="300" >3 hours each way (+ $300)</option>
<option value="400" >4 hours each way (+ $400)</option>
</select></p>

<p>Wedding album:
<select name="val6" class="text">
  <option value="0" selected>no album</option>
<option value="250" >Paganiphoto 8.5x11 Coffee Table ( up to 60 photos) (+ $250)</option>
<option value="450" >AsukaBook BookBound 10x10 (up to 120 photos) (+ $450)</option>
<option value="500" >AsukaBook BookBound EX 10x10 (up to 120 photos) (+ $500)</option>
<option value="850" >8x10 Sequoia (45 images) (+ $850)</option>
<option value="950" >10x10 Sequoia (45 images) (+ $950)</option>
<option value="1050" >10x15 Sequoia (45 images) (+ $1050)</option>
<option value="675" >8x10 Cypress "C" (75 images) (+ $675)</option>
<option value="750" >9x12 Cypress "C" (75 images) (+ $750)</option>
<option value="825" >11x11 Cypress "C" (75 images) (+ $825)</option>
<option value="900" >13x13 Cypress "C" (75 images) (+ $900)</option>
<option value="1200" >8x8 Cypress (45 images) (+ $1200)</option>
<option value="1350" >10x10 Cypress (45 images) (+ $1350)</option>
<option value="1600" >12x12 Cypress (45 images) (+ $1600)</option>
</select>
</p>

<p>Additional Wedding Album:
<select name="val7" class="text">
  <option value="0" selected>no album</option>
<option value="250" >Paganiphoto 8.5x11 Coffee Table ( up to 60 photos) (+ $250)</option>
<option value="450" >AsukaBook BookBound 10x10 (up to 120 photos) (+ $450)</option>
<option value="500" >AsukaBook BookBound EX 10x10 (up to 120 photos) (+ $500)</option>
<option value="850" >8x10 Sequoia (45 images) (+ $850)</option>
<option value="950" >10x10 Sequoia (45 images) (+ $950)</option>
<option value="1050" >10x15 Sequoia (45 images) (+ $1050)</option>
<option value="675" >8x10 Cypress "C" (75 images) (+ $675)</option>
<option value="750" >9x12 Cypress "C" (75 images) (+ $750)</option>
<option value="825" >11x11 Cypress "C" (75 images) (+ $825)</option>
<option value="900" >13x13 Cypress "C" (75 images) (+ $900)</option>
<option value="1200" >8x8 Cypress (45 images) (+ $1200)</option>
<option value="1350" >10x10 Cypress (45 images) (+ $1350)</option>
<option value="1600" >12x12 Cypress (45 images) (+ $1600)</option>
</select>
</p>

<p>Professional Print Credit: $<input type="text" name="val8" size="10" value= ></p>

<p>Proofing/Digital or Film Negatives:
<select name="val9" class="text">
  <option value="0" selected>full set of digital negatives (included)</option>
<option value="400" >wedding shot on filmfilm(+ $400)</option>
<option value="300" >silk or leather proof book(+ $300)</option>
<option value="425" >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">$1,700</span></span>
<input type="submit" name="submit" value="Reset" style="background-color: white; cursor: pointer; margin: 0 0 0 15px;">
</p>
  <p style="color:#CC0000;">
  </p></form>

 

and this is the php I have

<body>

<?php
if (($_POST[val1] == "") || ($_POST[val2] == "") || || ($_POST[val3] == "") || || ($_POST[val4] == "") || || ($_POST[val5] == "") || || ($_POST[val6] == "") || || ($_POST[val7] == "") || || ($_POST[val8] == "") || || ($_POST[val9] == "") || ($_POST[calc] =="")) {
  header("pricingaddition.php");
  exit;
}
if ($_POST[calc] == "add") {
  $result = $_POST[val1] + $_POST[val2] + $_POST[val3] + $_POST[val4] + $_POST[val5] + $_POST[val6] + $_POST[val7] + $_POST[val8] + $_POST[val9]
} 
echo "<title>Calculation Result</title>";
echo "<p>The result of the calculation is: $result</p>";
echo "<p><a href=\"calculate_form.html\" target=\"_self\">Do Another</a></p>";
?>
</body>

 

 

Thanks,

Stephen Houser

 

 

Link to comment
Share on other sites

Note, I renamed all the inputs "val[]" instead of val1, val2, ..., val9

 

<?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';

?>
<form method="post" action="">
<p>Second Photographer:
<select name="val[]" class="text">
  <option value="0" selected>no second photographer</option>
<option value="200" >2 hours (+ $200)</option>
<option value="300" >3 hours (+ $300)</option>
<option value="400" >4 hours (+ $400)</option>
<option value="500" >5 hours (+ $500)</option>
<option value="600" >6 hours (+ $600)</option>
<option value="700" >7 hours (+ $700)</option>
<option value="800" >8 hours (+ $800)</option>
</select>
</p>

<p>Wedding Day Coverage:
<select name="val[]" class="text">  
  <option value="0" selected>6 Hours (included)</option>
<option value="300" >7 Hours (+ 300)</option>
<option value="600" >8 Hours (+ 600)</option>
<option value="900" >9 Hours (+ 900)</option>
<option value="1200" >10 Hours (+ 1200)</option>
<option value="1500" >11 Hours (+ 1500)</option>
<option value="1800" >12 Hours (+ 1800)</option>

</select>
</p>

<p>Rehearsal Dinner Coverage:
<select name="val[]" class="text">
  <option value="0" selected>no coverage</option>
<option value="600" >2 Hours (+ 600)</option>
<option value="900" >4 Hours (+ 900)</option>
<option value="1200" >6 Hours (+ 1200)</option>

</select>
</p>

<p>Engagement Photo Session:
<select name="val[]" class="text">
  <option value="0" selected>no engagement photo session</option>
<option value="300" >engagement photo session (+ $300)</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="100" >1 hours each way (+ $100)</option>
<option value="200" >2 hours each way (+ $200)</option>
<option value="300" >3 hours each way (+ $300)</option>
<option value="400" >4 hours each way (+ $400)</option>
</select></p>

<p>Wedding album:
<select name="val[]" class="text">
  <option value="0" selected>no album</option>
<option value="250" >Paganiphoto 8.5x11 Coffee Table ( up to 60 photos) (+ $250)</option>
<option value="450" >AsukaBook BookBound 10x10 (up to 120 photos) (+ $450)</option>
<option value="500" >AsukaBook BookBound EX 10x10 (up to 120 photos) (+ $500)</option>
<option value="850" >8x10 Sequoia (45 images) (+ $850)</option>
<option value="950" >10x10 Sequoia (45 images) (+ $950)</option>
<option value="1050" >10x15 Sequoia (45 images) (+ $1050)</option>
<option value="675" >8x10 Cypress "C" (75 images) (+ $675)</option>
<option value="750" >9x12 Cypress "C" (75 images) (+ $750)</option>
<option value="825" >11x11 Cypress "C" (75 images) (+ $825)</option>
<option value="900" >13x13 Cypress "C" (75 images) (+ $900)</option>
<option value="1200" >8x8 Cypress (45 images) (+ $1200)</option>
<option value="1350" >10x10 Cypress (45 images) (+ $1350)</option>
<option value="1600" >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="250" >Paganiphoto 8.5x11 Coffee Table ( up to 60 photos) (+ $250)</option>
<option value="450" >AsukaBook BookBound 10x10 (up to 120 photos) (+ $450)</option>
<option value="500" >AsukaBook BookBound EX 10x10 (up to 120 photos) (+ $500)</option>
<option value="850" >8x10 Sequoia (45 images) (+ $850)</option>
<option value="950" >10x10 Sequoia (45 images) (+ $950)</option>
<option value="1050" >10x15 Sequoia (45 images) (+ $1050)</option>
<option value="675" >8x10 Cypress "C" (75 images) (+ $675)</option>
<option value="750" >9x12 Cypress "C" (75 images) (+ $750)</option>
<option value="825" >11x11 Cypress "C" (75 images) (+ $825)</option>
<option value="900" >13x13 Cypress "C" (75 images) (+ $900)</option>
<option value="1200" >8x8 Cypress (45 images) (+ $1200)</option>
<option value="1350" >10x10 Cypress (45 images) (+ $1350)</option>
<option value="1600" >12x12 Cypress (45 images) (+ $1600)</option>
</select>
</p>

<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="400" >wedding shot on filmfilm(+ $400)</option>
<option value="300" >silk or leather proof book(+ $300)</option>
<option value="425" >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"><?php echo $total ?></span></span>
<input type="submit" name="submit" value="Reset" style="background-color: white; cursor: pointer; margin: 0 0 0 15px;">
</p>
  <p style="color:#CC0000;">
  </p></form>

Link to comment
Share on other sites

Is there a way for the selections to remain visible after the total has been calculated.  I would like for the customer to be able to continue adding more items after they have calculated without having to reselect them. 

 

Thanks,

Stephen

Link to comment
Share on other sites

Yes, but with the options hard-coded like that it's a PIA. It's easiier if they come from a database (or array) then you can do the "selected" test in a loop

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

</select>
</p>

Link to comment
Share on other sites

Ok, I tried to do it like this, but no luck.  I wish I could buy you a beer for this!

<?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';

?>

<form method="post" action="">
<p>Second Photographer:
<select name="val[]" class="text">
  <option value="0" selected>no second photographer</option>
<option value="200" <?php echo $_POST['val'][2]==200 ? 'selected' : '' ?> >2 hours (+ $200)</option>
<option value="300" <?php echo $_POST['val'][2]==300 ? 'selected' : '' ?> >3 hours (+ $300)</option>
<option value="400" <?php echo $_POST['val'][2]==400 ? 'selected' : '' ?>>4 hours (+ $400)</option>
<option value="500" <?php echo $_POST['val'][2]==500 ? 'selected' : '' ?>>5 hours (+ $500)</option>
<option value="600" <?php echo $_POST['val'][2]==600 ? 'selected' : '' ?>>6 hours (+ $600)</option>
<option value="700" <?php echo $_POST['val'][2]==700 ? 'selected' : '' ?>>7 hours (+ $700)</option>
<option value="800" <?php echo $_POST['val'][2]==800 ? 'selected' : '' ?>>8 hours (+ $800)</option>
</select>
</p>

<p>Wedding Day Coverage:
<select name="val[]" class="text">  
  <option value="0" selected>6 Hours (included)</option>
<option value="300" <?php echo $_POST['val'][2]==300 ? 'selected' : '' ?>>7 Hours (+ 300)</option>
<option value="600" <?php echo $_POST['val'][2]==600 ? 'selected' : '' ?>>8 Hours (+ 600)</option>
<option value="900" <?php echo $_POST['val'][2]==900 ? 'selected' : '' ?>>9 Hours (+ 900)</option>
<option value="1200" <?php echo $_POST['val'][2]==1200 ? 'selected' : '' ?>>10 Hours (+ 1200)</option>
<option value="1500" <?php echo $_POST['val'][2]==1500 ? 'selected' : '' ?>>11 Hours (+ 1500)</option>
<option value="1800" <?php echo $_POST['val'][2]==1800 ? 'selected' : '' ?>>12 Hours (+ 1800)</option>

</select>
</p>

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

</select>
</p>

<p>Engagement Photo Session:
<select name="val[]" class="text">
  <option value="0" selected>no engagement photo session</option>
<option value="300" <?php echo $_POST['val'][2]==300 ? 'selected' : '' ?>>engagement photo session (+ $300)</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="100" <?php echo $_POST['val'][2]==100 ? 'selected' : '' ?> >1 hours each way (+ $100)</option>
<option value="200" <?php echo $_POST['val'][2]==200 ? 'selected' : '' ?> >2 hours each way (+ $200)</option>
<option value="300" <?php echo $_POST['val'][2]==300 ? 'selected' : '' ?> >3 hours each way (+ $300)</option>
<option value="400" <?php echo $_POST['val'][2]==400 ? 'selected' : '' ?> >4 hours each way (+ $400)</option>
</select></p>

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

<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="400" <?php echo $_POST['val'][2]==400 ? 'selected' : '' ?>>wedding shot on filmfilm(+ $400)</option>
<option value="300" <?php echo $_POST['val'][2]==300 ? 'selected' : '' ?> >silk or leather proof book(+ $300)</option>
<option value="425" <?php echo $_POST['val'][2]==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"><?php echo $total ?></span></span>
<input type="submit" name="submit" value="Reset" style="background-color: white; cursor: pointer; margin: 0 0 0 15px;">
</p>
  <p style="color:#CC0000;">
  </p></form>

 

 

Link to comment
Share on other sites

When I tried this it has disapeared completely.

 

<?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';

?>

<form method="post" action="">
<p>Second Photographer:
<select name="val[]" class="text">
  <option value="0" selected>no second photographer</option>
<option value="200" <?php echo $_POST['val'][0]==200 ? 'selected' : '' ?> >2 hours (+ $200)</option>
<option value="300" <?php echo $_POST['val'][1]==300 ? 'selected' : '' ?> >3 hours (+ $300)</option>
<option value="400" <?php echo $_POST['val'][2]==400 ? 'selected' : '' ?>>4 hours (+ $400)</option>
<option value="500" <?php echo $_POST['val'][3]==500 ? 'selected' : '' ?>>5 hours (+ $500)</option>
<option value="600" <?php echo $_POST['val'][4]==600 ? 'selected' : '' ?>>6 hours (+ $600)</option>
<option value="700" <?php echo $_POST['val'][5]==700 ? 'selected' : '' ?>>7 hours (+ $700)</option>
<option value="800" <?php echo $_POST['val'][6]==800 ? 'selected' : '' ?>>8 hours (+ $800)</option>
</select>
</p>

<p>Wedding Day Coverage:
<select name="val[]" class="text">  
  <option value="0" selected>6 Hours (included)</option>
<option value="300" <?php echo $_POST['val'][0]==300 ? 'selected' : '' ?>>7 Hours (+ 300)</option>
<option value="600" <?php echo $_POST['val'][1]==600 ? 'selected' : '' ?>>8 Hours (+ 600)</option>
<option value="900" <?php echo $_POST['val'][2==900 ? 'selected' : '' ?>>9 Hours (+ 900)</option>
<option value="1200" <?php echo $_POST['val'][3]==1200 ? 'selected' : '' ?>>10 Hours (+ 1200)</option>
<option value="1500" <?php echo $_POST['val'][4]==1500 ? 'selected' : '' ?>>11 Hours (+ 1500)</option>
<option value="1800" <?php echo $_POST['val'][5]==1800 ? 'selected' : '' ?>>12 Hours (+ 1800)</option>

</select>
</p>

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

</select>
</p>

<p>Engagement Photo Session:
<select name="val[]" class="text">
  <option value="0" selected>no engagement photo session</option>
<option value="300" <?php echo $_POST['val'][0]==300 ? 'selected' : '' ?>>engagement photo session (+ $300)</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="100" <?php echo $_POST['val'][0]==100 ? 'selected' : '' ?> >1 hours each way (+ $100)</option>
<option value="200" <?php echo $_POST['val'][1]==200 ? 'selected' : '' ?> >2 hours each way (+ $200)</option>
<option value="300" <?php echo $_POST['val'][2]==300 ? 'selected' : '' ?> >3 hours each way (+ $300)</option>
<option value="400" <?php echo $_POST['val'][3]==400 ? 'selected' : '' ?> >4 hours each way (+ $400)</option>
</select></p>

<p>Wedding album:
<select name="val[]" class="text">
  <option value="0" selected>no album</option>
<option value="250" <?php echo $_POST['val'][0]==250 ? 'selected' : '' ?> >Paganiphoto 8.5x11 Coffee Table ( up to 60 photos) (+ $250)</option>
<option value="450" <?php echo $_POST['val'][1]==450 ? 'selected' : '' ?> >AsukaBook BookBound 10x10 (up to 120 photos) (+ $450)</option>
<option value="500" <?php echo $_POST['val'][2]==500 ? 'selected' : '' ?> >AsukaBook BookBound EX 10x10 (up to 120 photos) (+ $500)</option>
<option value="850" <?php echo $_POST['val'][3]==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'][5]==1050 ? 'selected' : '' ?> >10x15 Sequoia (45 images) (+ $1050)</option>
<option value="675" <?php echo $_POST['val'][6]==675 ? 'selected' : '' ?> >8x10 Cypress "C" (75 images) (+ $675)</option>
<option value="750" <?php echo $_POST['val'][7]==750 ? 'selected' : '' ?> >9x12 Cypress "C" (75 images) (+ $750)</option>
<option value="825" <?php echo $_POST['val'][8]==825 ? 'selected' : '' ?> >11x11 Cypress "C" (75 images) (+ $825)</option>
<option value="900" <?php echo $_POST['val'][9]==900 ? 'selected' : '' ?>>13x13 Cypress "C" (75 images) (+ $900)</option>
<option value="1200" <?php echo $_POST['val'][10]==1200 ? 'selected' : '' ?>>8x8 Cypress (45 images) (+ $1200)</option>
<option value="1350" <?php echo $_POST['val'][11]==1350 ? 'selected' : '' ?>>10x10 Cypress (45 images) (+ $1350)</option>
<option value="1600" <?php echo $_POST['val'][12]==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="250" <?php echo $_POST['val'][0]==250 ? 'selected' : '' ?>>Paganiphoto 8.5x11 Coffee Table ( up to 60 photos) (+ $250)</option>
<option value="450" <?php echo $_POST['val'][1]==450 ? 'selected' : '' ?>>AsukaBook BookBound 10x10 (up to 120 photos) (+ $450)</option>
<option value="500" <?php echo $_POST['val'][2]==500 ? 'selected' : '' ?>>AsukaBook BookBound EX 10x10 (up to 120 photos) (+ $500)</option>
<option value="850" <?php echo $_POST['val'][3]==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'][5]==1050 ? 'selected' : '' ?>>10x15 Sequoia (45 images) (+ $1050)</option>
<option value="675" <?php echo $_POST['val'][6]==675 ? 'selected' : '' ?> >8x10 Cypress "C" (75 images) (+ $675)</option>
<option value="750" <?php echo $_POST['val'][7]==750 ? 'selected' : '' ?> >9x12 Cypress "C" (75 images) (+ $750)</option>
<option value="825" <?php echo $_POST['val'][8]==825 ? 'selected' : '' ?> >11x11 Cypress "C" (75 images) (+ $825)</option>
<option value="900" <?php echo $_POST['val'][9]==900 ? 'selected' : '' ?>>13x13 Cypress "C" (75 images) (+ $900)</option>
<option value="1200" <?php echo $_POST['val'][10]==1200 ? 'selected' : '' ?>>8x8 Cypress (45 images) (+ $1200)</option>
<option value="1350" <?php echo $_POST['val'][11]==1350 ? 'selected' : '' ?>>10x10 Cypress (45 images) (+ $1350)</option>
<option value="1600" <?php echo $_POST['val'][12]==1600 ? 'selected' : '' ?>>12x12 Cypress (45 images) (+ $1600)</option>
</select>
</p>

<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="400" <?php echo $_POST['val'][0]==400 ? 'selected' : '' ?>>wedding shot on filmfilm(+ $400)</option>
<option value="300" <?php echo $_POST['val'][1]==300 ? 'selected' : '' ?> >silk or leather proof book(+ $300)</option>
<option value="425" <?php echo $_POST['val'][2]==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"><?php echo $total ?></span></span>
<input type="reset" name="Reset" value="Reset" style="background-color: white; cursor: pointer; margin: 0 0 0 15px;">
</p>
  <p style="color:#CC0000;">
  </p></form>

 

 

Link to comment
Share on other sites

I'd say a little bit of javascript is best for that.

 

Javascript:

<script type="text/javascript">
function resetvalue(){
    document.getElementById('result_ans').innerHTML = '1,700';
    return true;
}
</script>

 

Modify your reset button to:

<input type="reset" name="Reset" value="Reset" onClick="resetvalue()" style="background-color: white; cursor: pointer; margin: 0 0 0 15px;">

 

And give the span tag an id:

 

<span class="result_ans" id="result_ans"><?php echo $total ?></span>

Link to comment
Share on other sites

  • 2 weeks later...

OK, so here is a new problem with this.  The calculation part works fine.  When I try to send the results via form e-mail, the problem is that I now have two submit buttons.  That means that when the user hits calculate, instead of calculating the price, it sends the e-mail.  I want to have all the selected values sent in an e-mail, but only after the user has been able to calculate the price and then submit the form.  With my server, I must use submit to send the e-mail, but is there perhaps another way to submit the calculation? 

 

Look at the code below and see if you understand what I am saying.

<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';

?>

<form method= "post" action="http://www.startlogic.com/scripts/formemail.bml">

<input type="hidden" name="my_email" value="jsh@jshphoto.net">
<input type="hidden" name="subject" value="Wedding Photography Request">


<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="250" <?php echo $_POST['val'][5]==250 ? 'selected' : '' ?>>Paganiphoto 8.5x11 Coffee Table ( up to 60 photos) (+ $250)</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>
  
  <fieldset>
  <legend>Email your package to Me </legend>
  <table cellpadding="2" cellspacing="0" border="0" style="border: 0px; background-color: #000000;">
  <tr>
  <td align="right"><label>Name</label></td>
  <td><input type="text" name="name" value=""></td>
  </tr>
   <tr>
  <td align="right"><label>Email</label></td>
  <td><input type="text" name="email" value=""></td>
  </tr>
   <tr>
  <td align="right"><label>Phone</label></td>
  <td><input type="text" name="phone" value=""></td>
  </tr>
  <tr>
  <td align="right"><label>Wedding Date<br>
  (dd/mm/yyyy)
  </label></td>
  <td><input name="weddingday" type="text" value="" size="2" maxlength="2">
  /
    <input name="weddingmonth" type="text" value="" size="2" maxlength="2">
    /
    <input name="weddingyear" type="text" value="" size="4" maxlength="4">
  </td>
  </tr>
   <tr>
  <td align="right" valign="top"><label>Comments</label></td>
  <td><textarea type="text" name="comments" value=""></textarea></td>
  </tr>
  <tr>
  <td> </td>
  <td align="left"><input type="submit" id="Form Submit" name="Form Submit"  value="Send Email" style="background-color: white; cursor: pointer;"></td>
  </tr>
  </table>
  </fieldset>
  </form>

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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