Jump to content

Recommended Posts

this is a very quick example of the kind of content I will have.

 

<form>
Required bit rate
<select>
  <option>128kbps</option>
  <option>192kbps</option>
  <option>240kbps</option>
  <option>320kbps</option>
</select><br />
Required listener ammount
<select>
  <option>up to 100</option>
  <option>up to 200</option>
  <option>up to 400</option>
  <option>400+</option>
</select><br />
Auto DJ? 
<select>
  <option>Yes</option>
  <option>No</option>
</select>
</form>

 

what i need is for the form to detect the value selected in the <option> and, depending on which are selected, add a set amount of money for each <option> and give a final total at the end =]

Link to comment
https://forums.phpfreaks.com/topic/173784-php-form/
Share on other sites

<form>
Required bit rate
<select name="bitrate">
  <option value="">128kbps</option>
  <option value="">192kbps</option>
  <option value="">240kbps</option>
  <option value="">320kbps</option>
</select><br />
Required listener ammount
<select name="listeners">
  <option value="">up to 100</option>
  <option value="">up to 200</option>
  <option value="">up to 400</option>
  <option value="">400+</option>
</select><br />
Auto DJ? 
<select name="dj">
  <option value="">Yes</option>
  <option value="">No</option>
</select>
<button type="submit" name="calculate">Calculate</button>
</form>

 

Add the price between " in the value="" for each.

 

if (isset($_POST['calculate'])) {
  $bitrate = floatval($_POST['bitrate']);
  $listeners = floatval($_POST['listeners']);
  $dj = floatval($_POST['dj']);
  
  print $bitrate + $listeners + $dj;
}

 

Note: This is an example and should not be used in production.

Link to comment
https://forums.phpfreaks.com/topic/173784-php-form/#findComment-916139
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.