Jump to content

Help finish my first javascript


ksduded

Recommended Posts

I am trying to make an instant quote calculator, but having some trouble. I want to display the result of the calculation in the textbox with id price.

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>OVP Custom Order</title>

<script language="javascript">
<!--

function calcul(){

var vmin = document.getElementById('dur_min')[document.getElementById('dur_min').selectedIndex].value;
var vsec = document.getElementById('dur_sec')[document.getElementById('dur_sec').selectedIndex].value;
var vscript = document.getElementById('script')[document.getElementById('script').selectedIndex].value;
var vvstock = document.getElementById('vis_stock')[document.getElementById('vis_stock').selectedIndex].value;
var vvvideo = document.getElementById('vis_video')[document.getElementById('vis_video').selectedIndex].value;
var vvanim = document.getElementById('vis_anim')[document.getElementById('vis_anim').selectedIndex].value;
var vvoice = document.getElementById('voice')[document.getElementById('voice').selectedIndex].value;
var vmusic = document.getElementById('music')[document.getElementById('music').selectedIndex].value;

vmin = vmin*1;
vsec = vsec*1;
vscript = vscript*1;
vvstock = vvstock*1;
vvvideo = vvvideo*1;
vvanim = vvanim*1;
vvoice = vvoice*1;
vvmusic = vvmusic*1;
var overhead = 547;
cost = (vmin+vsec)*(vscript+vvstock+vvvideo+vvanim+vvoice+vmusic+overhead);
document.getElementById('price').value = cost;

} 
// -->
</script>
</head>

<body>
<form id="form1" name="main">
  <label>Duration
  <select id="dur_min">
    <option value="0">0</option>
    <option value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option>
    <option value="4">4</option>
    <option value="5">5</option>
    <option value="6">6</option>
    <option value="7">7</option>
    <option value="8">8</option>
    <option value="9">9</option>
    <option value="10">10</option>
    <option value="11">11</option>
    <option value="12">12</option>
    <option value="13">13</option>
    <option value="14">14</option>
    <option value="15">15</option>
    <option value="16">16</option>
    <option value="17">17</option>
    <option value="18">18</option>
    <option value="19">19</option>
    <option value="20">20</option>
    <option value="21">21</option>
    <option value="22">22</option>
    <option value="23">23</option>
    <option value="24">24</option>
    <option value="25">25</option>
    <option value="26">26</option>
    <option value="27">27</option>
    <option value="28">28</option>
    <option value="29">29</option>
    <option value="30">30</option>
      </select>
  </label>
  mins 
  <label>
  <select name="dur_sec" id="dur_sec">
    <option value="0">00</option>
    <option value="0.25">15</option>
    <option value="0.5">30</option>
    <option value="0.75">45</option>
  </select>
  </label>
  seconds<br />
  <label><br />
  Script Provided by
  <select name="script" id="script">
    <option value="0">Client</option>
    <option value="200">OVP</option>
  </select>
  </label>
  <br />
  <br />
  Visuals<br />
  <label>
  <input value="100" type="checkbox" name="vis_stock" id="vis_stock" />
  Stock Image Library</label>
  <br />
  <label>
  <input value="300" type="checkbox" name="vis_video" id="vis_video" />
  Video Shoot</label>
  <br />
  <label>
  <input value="200" type="checkbox" name="vis_animation" id="vis_animation" />
  Animation & Graphics</label>
  <br />
  <label><br />
  Voiceovers
  <select name="voiceovers" id="voiceovers">
    <option value="0">No</option>
    <option value="200">Yes</option>
    </select>
  </label>
  <br />
  <label><br />
  Royalty Free Music
  <select name="music" id="music">
    <option value="0">No</option>
    <option value="50">Yes</option>
    </select>
  </label>
  <br />
  <br />
  Output Format(s)<br />
  <label>
  <input type="checkbox" name="out_web" id="out_web" />
  Web</label>
     
  <label>
  <input type="checkbox" name="out_dvd" id="out_dvd" />
  DVD</label>
     
  <label>
  <input type="checkbox" name="out_download" id="out_download" />
  Download</label>
  <br />
  <br />
  <label>
  <input type="submit" name="submit" id="submit" value="Calculate" onClick="calcul()"/>
  </label>
  <label>Approximate Price
  <input name="price" type="text" id="price" size="10" virtual warp="on" />
  </label>
  <br />
</form>
</body>
</html>

 

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.