Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Dec 2004
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Need help with calculations on form and looping

    Hello!! I am in need of any help I can get : ) I am soooo lost on this! I haven't had to do much with looping in JavaScript before...especially with calculations which is what I need help with. Basically, referring to the code below, I need to write a function that calculates an estimate based on certain checkboxes that are selected. I would like to have the value displayed in the text box next to the Calculate button...but, I only know how to use the Alert box to display values from a function. Here's the logic:

    If the small_sale checkbox is selected and Plots is selected
    THEN it will be $15.00
    (+) $6.25 for each check box selected for paper size
    (A, B, C, D, E)
    (Multiplied By) the value for the number of copies selected
    (Multiplied By) what is selected for materials...if Coated paper is selected (A = .50, B = 1.00, C = 2.25, D = 3.00, E = 6.00). If High Gloss Photo is selected for material (A=.50, B=1.00, C=13.50, D=18.00, E=36.00). If Matte Film is selected (A=.50, B=1.00, C=4.05, D=5.40, E=10.80)
    ELSE it will be $15.00 (+)
    If Orthophoto is checked then $6.25 or
    If Control is checked then $6.25 or
    If Hydrology is checked then $6.25 or
    If Parcel is checked then $6.25 or
    If Transportation is checked then $6.25 or
    If Topography is checked then $6.25 or
    If Laf Building Permit is checked then $6.25 (any one of the above can be checked for $6.25)
    (+)
    If DVD or CD-R is checked then add 7.00

    Wow! I know that is a lot to handle...If anyone can even help me get started on how to do this and work with me...I would really really appreciate it!! Let me know if my explanation is way too hard to understand.
    Here is my code:
    Code:
    <html>
    <head>
    <title>Tippecanoe County GIS Request Form</title>
    <style>
    
    </style>
    
    <script type="text/javascript" language="JavaScript">
    
    function calculateEstimate() {
       var small_hardcopy = 15;
       var papersize = 6.25;
       var paper_A = .50;
       var paper_B = 1.00;
       var paper_C = 2.25;
       var paper_D = 3.00;
       var paper_E = 6.00;
       var matte_C = 13.50;
       var matte_D = 18.00;
       var matte_E = 36.00;
       var photo_C = 4.05;
       var photo_D = 5.40;
       var photo_E = 10.80;
       var small = (document.frmGISRequest.small_sale.value)
       var hardcopy = (document.frmGISRequest.Plots.value)
       if (small == true && hardcopy == true)
         alert (small_hardcopy + papersize);
    
    }
    <!--// Written by: WillyDuitt\\-->
    
    function disableSelects(form){
        for(var i=0;i<form.elements.length;i++){
          if(form.elements[i].type.match(/select/i)){
             form.elements[i].disabled = 1;
          }
          if(form.elements[i].type.match(/checkbox/i)){
             form.elements[i].onclick = function(){
             this.parentNode.getElementsByTagName('select')[0].disabled =
             this.parentNode.getElementsByTagName('select')[0].disabled == 0 ? 1 : 0; 
            }
          }
        }
      }
    </script>
    </head>
    <body onload="disableSelects(document.forms['frmGISRequest'])">
    <form name="frmGISRequest" >
    <table border="0" width="900" align="center">
    <tr>
        <td><b>REQUESTING (Check all that apply):</b>&nbsp;&nbsp; 
        HARDCOPY PLOT
        <input type="checkbox" name="Plots" value="yes">&nbsp;&nbsp;&nbsp;&nbsp;
        DIGITAL DATA
        <input type="checkbox" name="Data" value="yes">
       </td>
    </tr>
    <tr>
        <td><b>SALE TYPE:</b>  &nbsp;&nbsp; 
        SMALL (1 sq. mile or smaller)
        <input type="checkbox" name="small_sale" value="yes">&nbsp;&nbsp;&nbsp;&nbsp;
        LARGE (Greater than 1 sq. mile) <b>**</b>
        <input type="checkbox" name="large_sale" value="yes">
       </td>
       <tr>
       <td>&nbsp;&nbsp;<b>(** If large data sale is selected, a GIS specialist will contact you with a cost estimate)</b></td>
       </tr>
    <tr>
        <td>&nbsp;</td>
    </tr>
    
    <table border="1" width="900" align="center">
    <tr>
    <td colspan="2" width = "100%"><b>PAPER SIZE:</b></td>
    </tr>
     <tr><td width = "15%">&nbsp;&nbsp;&nbsp;A(8 1/2" X 11")</td>
        <td width = "85%" align = "left">  <input type="checkbox" name="A" value="yes">&nbsp;&nbsp;&nbsp;
          <select name="COPIES_A">
            <option value="0">NUMBER OF COPIES
            <option value="1">1
            <option value="2">2
            <option value="3">3
            <option value="4">4
            <option value="5">5
          </select></td>
    </tr>
    <tr>
    <td width = "15%">&nbsp;&nbsp;&nbsp;B(11" X 17")</td>
         <td width = "85%" align = "left"><input type="checkbox" name="B" value="yes">&nbsp;&nbsp;&nbsp;
         <select name="COPIES_B">
            <option value="0">NUMBER OF COPIES
            <option value="1">1
            <option value="2">2
            <option value="3">3
            <option value="4">4
            <option value="5">5
          </select></td>
    </tr>
    <tr>
    <td width = "15%">
        &nbsp;&nbsp;&nbsp;C(18" X 24")</td>
        <td width = "85%" align = "left"><input type="checkbox" name="C" value="yes">&nbsp;&nbsp;&nbsp;
        <select name="COPIES_C">
            <option value="0">NUMBER OF COPIES
            <option value="1">1
            <option value="2">2
            <option value="3">3
            <option value="4">4
            <option value="5">5
          </select></td>
    </tr>
    <tr>
    <td width = "15%">
          &nbsp;&nbsp;&nbsp;D(24" X 36")</td>
          <td width = "85%" align = "left"><input type="checkbox" name=D" value="yes">&nbsp;&nbsp;&nbsp;
          <select name="COPIES_D">
            <option value="0">NUMBER OF COPIES
            <option value="1">1
            <option value="2">2
            <option value="3">3
            <option value="4">4
            <option value="5">5
          </select>
    </td>
    </tr>
    <tr>
      <td width = "15%">
          &nbsp;&nbsp;&nbsp;E(36" X 48")</td>
          <td width = "85%" align = "left"><input type="checkbox" name="E" value="yes">&nbsp;&nbsp;&nbsp;
          <select name="COPIES_E">
            <option value="0">NUMBER OF COPIES
            <option value="1">1
            <option value="2">2
            <option value="3">3
            <option value="4">4
            <option value="5">5
          </select>
    </td></tr>    
    <tr><td colspan = "2">&nbsp;</td>
    </tr>
    <tr>
        <td colspan="2"><b>MATERIAL:</b>&nbsp;&nbsp; 
        Paper
         <input type="checkbox" name="Coated Paper" value="yes">&nbsp;&nbsp;&nbsp;&nbsp;
        High Gloss Photo Paper
         <input type="checkbox" name="High Gloss Photo" value="yes">&nbsp;&nbsp;&nbsp;&nbsp;
        Matte Film
         <input type="checkbox" name="Matte Film" value="yes"></td>
    </tr>
    <tr>
        <td colspan="2"><b>SCALE (select one):</b>&nbsp;&nbsp; 
        1 in = &nbsp;&nbsp;&nbsp;100 ft
         <input type="checkbox" name="100 ft" value="yes">&nbsp;&nbsp;&nbsp;&nbsp;
        200 ft
         <input type="checkbox" name="200 ft" value="yes">&nbsp;&nbsp;&nbsp;&nbsp;
        </td>
    </tr>
    <tr>
        <td colspan="2">&nbsp;</td>
    </tr>
    </table>
    <table border="1" width="900" align="center">
    <tr>
        <td colspan="2" width="100%"><b>CATEGORIES:</td>
    </tr>
    <tr>    
    <td width="20%">&nbsp;&nbsp;&nbsp;Orthophotos</td>
         <td width="80%" align="left"><input type="checkbox" name="Orthophotos" value="yes"></td>
    </tr>
    <tr>
        <td width="20%">&nbsp;&nbsp;&nbsp;Control</td>
        <td width="80%" align="left"><input type="checkbox" name="Control" value="yes">
        (Surface Water Features)</td>
    </tr>
    <tr>
       
        <td width="20%">&nbsp;&nbsp;&nbsp;Hydrology</td>
        <td width="80%" align="left"><input type="checkbox" name="Hydrology" value="yes">
        (Surface Water Features)</td>
    </tr>
    <tr>
       
       <td width="20%">
        &nbsp;&nbsp;&nbsp;Parcel</td>
        <td width="80%" align="left"><input type="checkbox" name="Parcel" value="yes">
       (Property Lines and Key Numbers)</td>
    </tr>   
    <tr>
    <td width="20%">
        
       &nbsp;&nbsp;&nbsp;Transportation</td>
       <td width="80%" align="left"><input type="checkbox" name="Hydrology" value="yes">
        (Road Centerline and Road Name)</td>
    </tr>    
    <tr>
        
        <td width="20%">&nbsp;&nbsp;&nbsp;Topography</td>
        <td width="80%" align="left"><input type="checkbox" name="Topography" value="yes">
        (2 ft. and/or 10 ft. Contours)</td>
    </tr>
    <tr>    
        <td width="20%">
        &nbsp;&nbsp;&nbsp;Lafayette Bldg Footprint</td>
        <td width="80%" align="left"><input type="checkbox" name="Laf Building Permit" value="yes">&nbsp;(Building Outline)</td>
    </tr>
    <tr><td colspan="2">&nbsp;</td></tr>
    </table>
    <table border="1" width="900" align="center">
    <tr>
        <td><b>DIGITAL VECTOR FORMAT:</b>&nbsp;&nbsp;&nbsp; 
        .DGN
        <input type="checkbox" name=".DGN" value="yes">&nbsp;&nbsp;&nbsp;&nbsp;
        .DXF
        <input type="checkbox" name=".DXF" value="yes">&nbsp;&nbsp;&nbsp;&nbsp;
        DWG
        <input type="checkbox" name=".DWG" value="yes">&nbsp;&nbsp;&nbsp;&nbsp;
        CAD .DWG VERSION (up to 2004)&nbsp;&nbsp;<input type="checkbox" name="CAD" value="yes">&nbsp;&nbsp;
        <select name="CAD_VERSION" disabled="false">
            <option value="0">VERSION
            <option value="1">11/12
            <option value="2">14
            <option value="3">2000
            <option value="4">2004
        </select></td>
    </tr>
    <tr>
        <td><b>DIGITAL RASTER FORMAT (Aerial Photos):</b>&nbsp;&nbsp;&nbsp; 
        .COT
        <input type="checkbox" name=".COT" value="yes">&nbsp;&nbsp;&nbsp;&nbsp;
        .TIF (8-bit uncompressed) & .TFW
        <input type="checkbox" name=".TIF_.TFW" value="yes"></td>
    </tr>   
    <tr>
        <td><b>DIGITAL CONTOUR FORMAT (Topography):</b>&nbsp;&nbsp;&nbsp; 
        2D-DGN
        <input type="checkbox" name="2D_DGN" value="yes">&nbsp;&nbsp;&nbsp;&nbsp;
        3D-DGN
        <input type="checkbox" name="3D_DGN" value="yes">&nbsp;&nbsp;&nbsp;&nbsp;
        3D-DXF
        <input type="checkbox" name="3D_DXF" value="yes">&nbsp;&nbsp;&nbsp;&nbsp;
        2D-DWG
        <input type="checkbox" name="2D_DWG" value="yes">&nbsp;&nbsp;&nbsp;&nbsp;
        3D-DWG
        <input type="checkbox" name="3D_DWG" value="yes"></td>
    </tr>
    <tr>
        <td>&nbsp;</td>
    </tr>
    
    <tr>
        <td><b>DIGITAL MEDIA:</b> 
        CD-R(640MB)
        <input type="checkbox" name="CD-R" value="yes">&nbsp;&nbsp;&nbsp;&nbsp;
        DVD (4.5MB)
        <input type="checkbox" name="CD-R" value="yes">&nbsp;&nbsp;&nbsp;&nbsp;
        E-MAIL(2MB)
        <input type="checkbox" name="E-Mail Request" value="yes">&nbsp;&nbsp;&nbsp;&nbsp;</td>
    </tr>
    <tr><td align="center"><input type="text" name="estimate" size=25 maxlength=25>&nbsp;&nbsp;&nbsp;&nbsp;<input type="submit" 
    
    value="Calculate" onclick="calculateEstimate()"></td></tr>
    </table>
    </form>
    </body>
    </html>
    Thank You in Advance for Your Time!

    Shannon
    Last edited by sueberry; 12-21-2004 at 09:01 PM.

  • #2
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I do not understand the conditions of your total but then again I did not look very hard at that since when I ran your codes I noticed that you never updated the script I wrote for you here and since you have added all these new fields it is throwing errors throughout the entire document...

    Firstly, you need to fix these errors in order to make your document functional enough to even work with another script to calculate the total...

    Change the previous function I wrote with this one:

    Code:
      function disableSelects(form){
        for(var i=0;i<form.elements.length;i++){
         var input = form.elements[i];
          if(input.type.match(/select/i) && 
             input.name.match(/^copies_/i)){ 
             input.disabled = 1;
          }
          if(input.type.match(/checkbox/i) && 
             input.parentNode.getElementsByTagName('select')[0] && 
             input.parentNode.getElementsByTagName('select')[0].name.match(/^copies_/i)){ 
             input.onclick = function(){
               var select = this.parentNode.getElementsByTagName('select')[0];
                   select.disabled = select.disabled == 0 ? 1 : 0; 
            }
          }
        }
      }
    And I'm not sure what is going on with this select:
    <select name="CAD_VERSION" disabled="false">

    But I would assume you do not wish it to be included with the above function... If so, remove disabled="false" so that it works properly...

    .....Willy

  • #3
    New Coder
    Join Date
    Dec 2004
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Fixed function - Sorry about the mess

    Thank you for your quick response...I added the correct function...Sorry about that, I didn't even notice that there were errors when I opened it in the browser. I thought if I added a checkbox in front of the CAD version select box, it would work just like the other option fields...I didn't realize that having all of the other check boxes messed it up...duhhhh!! The updated calculations and code are below. Let me know what you don't understand about the calculations...I added numbers after each section for reference and the names in quotes are the names of the fields:

    If the "small_sale" checkbox is selected and "Plots" is selected
    THEN it will be $15.00 (1.)
    (PLUS) $6.25 for each check box selected for paper size
    ("A", "B", "C", "D", "E") - it can be more than one (2.)
    (Multiplied By) the value for the number of copies selected from the drop down box (option values 1 - 5 from select names "COPIES_A", "COPIES_B", "COPIES_C", "COPIES_D", "COPIES_E") (3.)
    (Multiplied By) what is selected for materials...if "Coated Paper" is selected (A = .50, B = 1.00, C = 2.25, D = 3.00, E = 6.00). If "High Gloss Photo" is selected for material (A=.50, B=1.00, C=13.50, D=18.00, E=36.00). If "Matte Film" is selected (A=.50, B=1.00, C=4.05, D=5.40, E=10.80) (4.)
    ELSE it will be $15.00 (PLUS)
    If "Orthophoto" is checked then $6.25 or
    If "Control" is checked then $6.25 or
    If "Hydrology" is checked then $6.25 or
    If "Parcel" is checked then $6.25 or
    If "Transportation" is checked then $6.25 or
    If "Topography" is checked then $6.25 or
    If "Laf Building Permit" is checked then $6.25 (any one of the above can be checked for $6.25) (5.)
    (PLUS)
    If "DVD" or "CD-R" is checked then add 7.00 (6.)

    Here's the updated code:

    Code:
    <html>
    <head>
    <title>Tippecanoe County GIS Request Form</title>
    <style>
    
    </style>
    
    <script type="text/javascript" language="JavaScript">
    
    function calculateEstimate() {
       var small_hardcopy = 15;
       var papersize = 6.25;
       var paper_A = .50;
       var paper_B = 1.00;
       var paper_C = 2.25;
       var paper_D = 3.00;
       var paper_E = 6.00;
       var matte_C = 13.50;
       var matte_D = 18.00;
       var matte_E = 36.00;
       var photo_C = 4.05;
       var photo_D = 5.40;
       var photo_E = 10.80;
       var small = (document.frmGISRequest.small_sale.value)
       var hardcopy = (document.frmGISRequest.Plots.value)
       if (small == true && hardcopy == true)
         alert (small_hardcopy + papersize);
    
    }
    <!--// Written by: WillyDuitt\\-->
    
    function disableSelects(form){
        for(var i=0;i<form.elements.length;i++){
         var input = form.elements[i];
          if(input.type.match(/select/i) && 
             input.name.match(/^copies_/i)){ 
             input.disabled = 1;
          }
          if(input.type.match(/checkbox/i) && 
             input.parentNode.getElementsByTagName('select')[0] && 
             input.parentNode.getElementsByTagName('select')[0].name.match(/^copies_/i)){ 
             input.onclick = function(){
               var select = this.parentNode.getElementsByTagName('select')[0];
                   select.disabled = select.disabled == 0 ? 1 : 0; 
            }
          }
        }
      }
    
    </script>
    </head>
    <body onload="disableSelects(document.forms['frmGISRequest'])">
    <form name="frmGISRequest">
    <table border="0" width="900" align="center">
    <tr>
        <td><b>REQUESTING (Check all that apply):</b>&nbsp;&nbsp; 
        HARDCOPY PLOT
        <input type="checkbox" name="Plots" value="yes">&nbsp;&nbsp;&nbsp;&nbsp;
        DIGITAL DATA
        <input type="checkbox" name="Data" value="yes">
       </td>
    </tr>
    <tr>
        <td><b>SALE TYPE:</b>  &nbsp;&nbsp; 
        SMALL (1 sq. mile or smaller)
        <input type="checkbox" name="small_sale" value="yes">&nbsp;&nbsp;&nbsp;&nbsp;
        LARGE (Greater than 1 sq. mile) <b>**</b>
        <input type="checkbox" name="large_sale" value="yes">
       </td>
       <tr>
       <td>&nbsp;&nbsp;<b>(** If large data sale is selected, a GIS specialist will contact you with a cost estimate)</b></td>
       </tr>
    <tr>
        <td>&nbsp;</td>
    </tr>
    
    <table border="1" width="900" align="center">
    <tr>
    <td colspan="2" width = "100%"><b>PAPER SIZE:</b></td>
    </tr>
     <tr><td width = "15%">&nbsp;&nbsp;&nbsp;A(8 1/2" X 11")</td>
        <td width = "85%" align = "left">  <input type="checkbox" name="A" value="yes">&nbsp;&nbsp;&nbsp;
          <select name="COPIES_A">
            <option value="0">NUMBER OF COPIES
            <option value="1">1
            <option value="2">2
            <option value="3">3
            <option value="4">4
            <option value="5">5
          </select></td>
    </tr>
    <tr>
    <td width = "15%">&nbsp;&nbsp;&nbsp;B(11" X 17")</td>
         <td width = "85%" align = "left"><input type="checkbox" name="B" value="yes">&nbsp;&nbsp;&nbsp;
         <select name="COPIES_B">
            <option value="0">NUMBER OF COPIES
            <option value="1">1
            <option value="2">2
            <option value="3">3
            <option value="4">4
            <option value="5">5
          </select></td>
    </tr>
    <tr>
    <td width = "15%">
        &nbsp;&nbsp;&nbsp;C(18" X 24")</td>
        <td width = "85%" align = "left"><input type="checkbox" name="C" value="yes">&nbsp;&nbsp;&nbsp;
        <select name="COPIES_C">
            <option value="0">NUMBER OF COPIES
            <option value="1">1
            <option value="2">2
            <option value="3">3
            <option value="4">4
            <option value="5">5
          </select></td>
    </tr>
    <tr>
    <td width = "15%">
          &nbsp;&nbsp;&nbsp;D(24" X 36")</td>
          <td width = "85%" align = "left"><input type="checkbox" name=D" value="yes">&nbsp;&nbsp;&nbsp;
          <select name="COPIES_D">
            <option value="0">NUMBER OF COPIES
            <option value="1">1
            <option value="2">2
            <option value="3">3
            <option value="4">4
            <option value="5">5
          </select>
    </td>
    </tr>
    <tr>
      <td width = "15%">
          &nbsp;&nbsp;&nbsp;E(36" X 48")</td>
          <td width = "85%" align = "left"><input type="checkbox" name="E" value="yes">&nbsp;&nbsp;&nbsp;
          <select name="COPIES_E">
            <option value="0">NUMBER OF COPIES
            <option value="1">1
            <option value="2">2
            <option value="3">3
            <option value="4">4
            <option value="5">5
          </select>
    </td></tr>    
    <tr><td colspan = "2">&nbsp;</td>
    </tr>
    <tr>
        <td colspan="2"><b>MATERIAL:</b>&nbsp;&nbsp; 
        Paper
         <input type="checkbox" name="Coated Paper" value="yes">&nbsp;&nbsp;&nbsp;&nbsp;
        High Gloss Photo Paper
         <input type="checkbox" name="High Gloss Photo" value="yes">&nbsp;&nbsp;&nbsp;&nbsp;
        Matte Film
         <input type="checkbox" name="Matte Film" value="yes"></td>
    </tr>
    <tr>
        <td colspan="2"><b>SCALE (select one):</b>&nbsp;&nbsp; 
        1 in = &nbsp;&nbsp;&nbsp;100 ft
         <input type="checkbox" name="100 ft" value="yes">&nbsp;&nbsp;&nbsp;&nbsp;
        200 ft
         <input type="checkbox" name="200 ft" value="yes">&nbsp;&nbsp;&nbsp;&nbsp;
        </td>
    </tr>
    <tr>
        <td colspan="2">&nbsp;</td>
    </tr>
    </table>
    <table border="1" width="900" align="center">
    <tr>
        <td colspan="2" width="100%"><b>CATEGORIES:</td>
    </tr>
    <tr>    
    <td width="20%">&nbsp;&nbsp;&nbsp;Orthophotos</td>
         <td width="80%" align="left"><input type="checkbox" name="Orthophotos" value="yes"></td>
    </tr>
    <tr>
        <td width="20%">&nbsp;&nbsp;&nbsp;Control</td>
        <td width="80%" align="left"><input type="checkbox" name="Control" value="yes">
        (Surface Water Features)</td>
    </tr>
    <tr>
       
        <td width="20%">&nbsp;&nbsp;&nbsp;Hydrology</td>
        <td width="80%" align="left"><input type="checkbox" name="Hydrology" value="yes">
        (Surface Water Features)</td>
    </tr>
    <tr>
       
       <td width="20%">
        &nbsp;&nbsp;&nbsp;Parcel</td>
        <td width="80%" align="left"><input type="checkbox" name="Parcel" value="yes">
       (Property Lines and Key Numbers)</td>
    </tr>   
    <tr>
    <td width="20%">
        
       &nbsp;&nbsp;&nbsp;Transportation</td>
       <td width="80%" align="left"><input type="checkbox" name="Hydrology" value="yes">
        (Road Centerline and Road Name)</td>
    </tr>    
    <tr>
        
        <td width="20%">&nbsp;&nbsp;&nbsp;Topography</td>
        <td width="80%" align="left"><input type="checkbox" name="Topography" value="yes">
        (2 ft. and/or 10 ft. Contours)</td>
    </tr>
    <tr>    
        <td width="20%">
        &nbsp;&nbsp;&nbsp;Lafayette Bldg Footprint</td>
        <td width="80%" align="left"><input type="checkbox" name="Laf Building Permit" value="yes">&nbsp;(Building Outline)</td>
    </tr>
    <tr><td colspan="2">&nbsp;</td></tr>
    </table>
    <table border="1" width="900" align="center">
    <tr>
        <td><b>DIGITAL VECTOR FORMAT:</b>&nbsp;&nbsp;&nbsp; 
        .DGN
        <input type="checkbox" name=".DGN" value="yes">&nbsp;&nbsp;&nbsp;&nbsp;
        .DXF
        <input type="checkbox" name=".DXF" value="yes">&nbsp;&nbsp;&nbsp;&nbsp;
        DWG
        <input type="checkbox" name=".DWG" value="yes">&nbsp;&nbsp;&nbsp;&nbsp;
        CAD .DWG VERSION (up to 2004)&nbsp;&nbsp;<input type="checkbox" name="CAD" value="yes">&nbsp;&nbsp;
        <select name="CAD_VERSION">
            <option value="0">VERSION
            <option value="1">11/12
            <option value="2">14
            <option value="3">2000
            <option value="4">2004
        </select></td>
    </tr>
    <tr>
        <td><b>DIGITAL RASTER FORMAT (Aerial Photos):</b>&nbsp;&nbsp;&nbsp; 
        .COT
        <input type="checkbox" name=".COT" value="yes">&nbsp;&nbsp;&nbsp;&nbsp;
        .TIF (8-bit uncompressed) & .TFW
        <input type="checkbox" name=".TIF_.TFW" value="yes"></td>
    </tr>   
    <tr>
        <td><b>DIGITAL CONTOUR FORMAT (Topography):</b>&nbsp;&nbsp;&nbsp; 
        2D-DGN
        <input type="checkbox" name="2D_DGN" value="yes">&nbsp;&nbsp;&nbsp;&nbsp;
        3D-DGN
        <input type="checkbox" name="3D_DGN" value="yes">&nbsp;&nbsp;&nbsp;&nbsp;
        3D-DXF
        <input type="checkbox" name="3D_DXF" value="yes">&nbsp;&nbsp;&nbsp;&nbsp;
        2D-DWG
        <input type="checkbox" name="2D_DWG" value="yes">&nbsp;&nbsp;&nbsp;&nbsp;
        3D-DWG
        <input type="checkbox" name="3D_DWG" value="yes"></td>
    </tr>
    <tr>
        <td>&nbsp;</td>
    </tr>
    
    <tr>
        <td><b>DIGITAL MEDIA:</b> 
        CD-R(640MB)
        <input type="checkbox" name="CD-R" value="yes">&nbsp;&nbsp;&nbsp;&nbsp;
        DVD (4.5MB)
        <input type="checkbox" name="DVD" value="yes">&nbsp;&nbsp;&nbsp;&nbsp;
        E-MAIL(2MB)
        <input type="checkbox" name="E-Mail Request" value="yes">&nbsp;&nbsp;&nbsp;&nbsp;</td>
    </tr>
    <tr><td align="center"><input type="text" name="estimate" size=25 maxlength=25>&nbsp;&nbsp;&nbsp;&nbsp;<input type="submit" 
    
    value="Calculate" onclick="calculateEstimate()"></td></tr>
    </table>
    </form>
    </body>
    </html>
    Last edited by sueberry; 12-21-2004 at 09:02 PM.

  • #4
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by sueberry
    I thought if I added a checkbox in front of the CAD version select box, it would work just like the other option fields...I didn't realize that having all of the other check boxes messed it up...duhhhh!!
    Actually, all of the errors being thrown went much deeper than more than one checkbox in the data cell... The problems were that every checkbox was having an onclick event handler appended to it regardless if there was a select included within the data cell... However, when I wrote that, your entire form only consisted of a few data cells which included a checkbox and a select....

    Anyway, if you want to also disable the CAD_VERSION select and toggle it with the CAD checkbox.... Make the following changes highlighted in red....

    Code:
      function disableSelects(form){
        for(var i=0;i<form.elements.length;i++){
         var input = form.elements[i];
          if(input.type.match(/select/i) && 
             input.name.match(/^copies_|cad_/i)){ 
             input.disabled = 1;
          }
          if(input.type.match(/checkbox/i) && 
             input.parentNode.getElementsByTagName('select')[0] && 
             input.parentNode.getElementsByTagName('select')[0].name.match(/^copies_/i) ||
             input.name.match(/^cad$/i)){
             input.onclick = function(){
               var select = this.parentNode.getElementsByTagName('select')[0];
                   select.disabled = select.disabled == 0 ? 1 : 0;
            }
          }
        }
      }
    Also, I am still confused about what is going on within the DIGITAL VECTOR FORMAT: data cell and all of those checkboxes... Can a user choose more than one checkbox?? If not, radio buttons would be more appropriate...

    .....Willy

    BTW: If you are scripting in javascript, make sure you enable error reporting in the advanced tab on the toolbar... Without error reporting turned on, you will never know where to look for script errors or perhaps that any are present...

    Edit: Fixed logic error
    Last edited by Willy Duitt; 12-30-2004 at 12:36 AM.

  • #5
    New Coder
    Join Date
    Dec 2004
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Willy,

    Thank you so much for your time on this...Actually, the Digital Vector Format, Raster Format, and Contour Format parts don't have anything to do with the calculations. I really want help on figuring out the JavaScript so once the form is all finished, the user's can see an estimation based on what they have selected relating to the Sale Type, Paper Size, Number of Copies, and Material, and Categories. I'm going to take the checkbox out that is next to the CAD version, so they just select a version...the only reason I put that there is because I misunderstood what the function was doing. A user can choose more than one option on the Digital Vector Format section of the form. Do you understand the logic on the calculations?

    Thank you for the tip on the error handling...I did not know that.

    Shannon

  • #6
    New Coder
    Join Date
    Dec 2004
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Can anyone help with this??

    Is there anyone that can help me out with this...all the info is in the above postings.

    Thanks,
    Shannon
    Last edited by sueberry; 12-28-2004 at 02:57 PM.

  • #7
    New Coder
    Join Date
    Dec 2004
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    If statement and help with calculations

    I am having a lot of trouble with the If statement for this calculation. If there is anyone that could work through this with me, I would really appreciate it! I can't figure out if I should do an array for this or just have a complex If statement...either way I really need some guidance. I am very new to this and any help would be awesome! Thank You.

    Shannon


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •