Community Forums 

Main Content

multiple price option for drop down menu

    Jul 12 2016 18:50:44

    #1

    GT

    Join date : 2008-09-18      Posts : 3207

    Email me and I'll build you a script if you don't know how :)

    Having trouble with a form or need one building?
    Fast turnaround, but I do charge :)

    Mal's Forms / Scripts and the syntax are here.




    Jul 12 2016 19:58:41

    #2

    Tomele

    Join date : 2016-07-11      Posts : 23

    GT said Email me and I'll build you a script if you don't know how :)

    -------------------------
    mail to where?



    Jul 12 2016 20:05:48

    #3

    Tomele

    Join date : 2016-07-11      Posts : 23

    Why is this not working





    <script type="text/javascript">
    //<![CDATA[
    function submitForm() {
    /*
    When the form is submitted, these fields are tested for blanks.
    If it is ok to have a blank, then just remove that group.
    Bear in mind though that if you remove a group here, you need to remove all references
    to it in the rest of the page and to do this you would need good javascript knowledge
    so that you don't remove wrong areas of code.
    */
    if (document.myForm.Days.value=='') {
    alert('Please Select No. of Days');
    return false;
    }
    if (document.myForm.campArea.value=='select') {
    alert('Please Select your Camp Area');
    return false;
    }
    if (document.myForm.campSite.value=='select') {
    alert('Please Select your Campsite');
    return false;
    }
    if (document.myForm.noCampers.value=='') {
    alert('Please Select number of Campers');
    return false;
    }
    /*
    If the above tests are all ok, then the script then creates the total
    */
    sumFields();
    }

    function sumFields() {
    /*
    This function generates the price and product fields based on the users input.
    The price is stored in a field called tmpPrice and is incremented as it goes down the script.
    at the end of the script it is multiplied by the number of days and stored into the
    forms price field.
    The description is stored in a field called tmpDescription and like tmpPrice is built
    as the script runs through. It is then stored into the forms product field.
    */
    var tmpPrice=0;
    var tmpField=0;
    var tmpArray=new Array();
    tmpField=document.myForm.campArea.value;
    tmpArray = tmpField.split(':');
    var tmpCampArea=tmpArray[0];
    var tmpDescription='{b}'+tmpCampArea+document.myForm.campSite.value+'{/b}{br}'+document.myForm.Days.value+' Day';
    if (document.myForm.Days.value>1) {
    /*
    All this next line of code does (and any others like it) is add an s to the end of the description
    for more than one item.
    */
    tmpDescription+='s';
    }
    tmpField=document.myForm.noCampers.value;
    tmpArray = tmpField.split(':');
    tmpDescription+='{br}'+tmpArray[0];
    tmpPrice+=(1*tmpArray[1]);
    /*
    The following group of code (starting with if and ending with } ) is what is required for
    all your drop boxes that contain a description and a price setout in the traditional way as
    Mal's productpr field.
    Basically it first checks if the user has selected from the list and if so, runs the code.
    It splits the field into two fields around the : symbol.
    It then adds the first field ( tmpArray[0] ) to the temp field for description and adds the second
    field ( tmpArray[1] ) to the temp field for price.
    */
    if (document.myForm.addPadding.value>'') {
    tmpField=document.myForm.addPadding.value;
    tmpArray = tmpField.split(':');
    tmpDescription+='{br}'+tmpArray[0];
    tmpPrice+=(1*tmpArray[1]);
    }
    if (document.myForm.carpetSquares.value>'') {
    tmpField=document.myForm.carpetSquares.value;
    tmpArray = tmpField.split(':');
    tmpDescription+=', '+tmpArray[0];
    tmpPrice+=(1*tmpArray[1]);
    }
    if (document.myForm.gazebo.value>'') {
    tmpField=document.myForm.gazebo.value;
    tmpArray = tmpField.split(':');
    tmpDescription+=', '+tmpArray[0];
    tmpPrice+=(1*tmpArray[1]);
    }
    if (document.myForm.canopy.value>'') {
    tmpField=document.myForm.canopy.value;
    tmpArray = tmpField.split(':');
    tmpDescription+=', '+tmpArray[0];
    tmpPrice+=(1*tmpArray[1]);
    }
    /*
    This next group of code is for check boxes.
    It looks to see if it has been checked and if so, again adds to the description and price fields
    */
    if (document.myForm.shelter.checked==1) {
    tmpDescription+=', 3x3 Privacy Shelter';
    tmpPrice+=(1*document.myForm.shelterPrice.value);
    }
    /*
    This next group of code is for standard text boxes where you would normally ust qty.
    It looks to see if it has entered a value and if so, multiplies it by the price for that
    option and adds it to the tmpPrice field. Also adds in the description.
    */
    if (document.myForm.sleepingBag.value>0) {
    tmpDescription+='{br}'+document.myForm.sleepingBag.value+' Sleeping Bag';
    if (document.myForm.sleepingBag.value>1) {
    tmpDescription+='s';
    }
    tmpPrice+=(1*document.myForm.sleepingBag.value*document.myForm.sleepingBagPrice.value);
    }
    if (document.myForm.foamMatA.value>0) {
    tmpDescription+=', '+document.myForm.foamMatA.value+' 1/4" Ground Mat';
    if (document.myForm.foamMatA.value>1) {
    tmpDescription+='s';
    }
    tmpPrice+=(1*document.myForm.foamMatA.value*document.myForm.foamMatAPrice.value);
    }
    if (document.myForm.foamMatB.value>0) {
    tmpDescription+=', '+document.myForm.foamMatB.value+' 1/2" Ground Mat';
    if (document.myForm.foamMatB.value>1) {
    tmpDescription+='s';
    }
    tmpPrice+=(1*document.myForm.foamMatB.value*document.myForm.foamMatBPrice.value);
    }
    if (document.myForm.adultCot.value>0) {
    tmpDescription+=', '+document.myForm.adultCot.value+' Adult Cot';
    if (document.myForm.adultCot.value>1) {
    tmpDescription+='s';
    }
    tmpPrice+=(1*document.myForm.adultCot.value*document.myForm.adultCotPrice.value);
    }
    if (document.myForm.childCot.value>0) {
    tmpDescription+=', '+document.myForm.childCot.value+' Child Cot';
    if (document.myForm.childCot.value>1) {
    tmpDescription+='s';
    }
    tmpPrice+=(1*document.myForm.childCot.value*document.myForm.childCotPrice.value);
    }
    if (document.myForm.blanket.value>0) {
    tmpDescription+=', '+document.myForm.blanket.value+' Extra Blanket';
    if (document.myForm.blanket.value>1) {
    tmpDescription+='s';
    }
    tmpPrice+=(1*document.myForm.blanket.value*document.myForm.blanketPrice.value);
    }
    if (document.myForm.tableBurner.checked==1) {
    tmpDescription+='{br}Tabletop 2 Burner Stove';
    tmpPrice+=(1*document.myForm.tableBurnerPrice.value);
    }
    if (document.myForm.standingBurner.checked==1) {
    tmpDescription+=', Standing 2 Burner Stove';
    tmpPrice+=(1*document.myForm.standingBurnerPrice.value);
    }
    if (document.myForm.table4x4.value>0) {
    tmpDescription+=', '+document.myForm.table4x4.value+' 4x4 Table';
    if (document.myForm.table4x4.value>1) {
    tmpDescription+='s';
    }
    tmpPrice+=(1*document.myForm.table4x4.value*document.myForm.table4x4Price.value);
    }
    if (document.myForm.table3x6.value>0) {
    tmpDescription+=', '+document.myForm.table3x6.value+' 3x6 Table';
    if (document.myForm.table3x6.value>1) {
    tmpDescription+='s';
    }
    tmpPrice+=(1*document.myForm.table3x6.value*document.myForm.table3x6Price.value);
    }
    if (document.myForm.cookset.checked==1) {
    tmpPrice+=(1*document.myForm.cooksetPrice.value);
    tmpDescription+=', Cookset';
    }
    if (document.myForm.coffeeMaker.checked==1) {
    tmpDescription+=', Coffee Maker';
    tmpPrice+=(1*document.myForm.coffeeMakerPrice.value);
    }
    if (document.myForm.cookingStation.checked==1) {
    tmpDescription+=', Cooking Station';
    tmpPrice+=(1*document.myForm.cookingStationPrice.value);
    }
    if (document.myForm.placeSetting.value>'') {
    tmpField=document.myForm.placeSetting.value;
    tmpArray = tmpField.split(':');
    tmpDescription+=', '+tmpArray[0];
    tmpPrice+=(1*tmpArray[1]);
    }
    if (document.myForm.washBin.checked==1) {
    tmpDescription+=', 2 Plastic Wash Bins';
    tmpPrice+=(1*document.myForm.washBinPrice.value);
    }
    if (document.myForm.dishClothes.checked==1) {
    tmpDescription+=', Dish Clothes';
    tmpPrice+=(1*document.myForm.dishClothesPrice.value);
    }
    if (document.myForm.castIronSkillet.checked==1) {
    tmpDescription+='{br}Cast Iron Skillet (Campfire Cooking)';
    tmpPrice+=(1*document.myForm.castIronSkilletPrice.value);
    }
    if (document.myForm.hotDogStick.value>0) {
    tmpDescription+=', '+document.myForm.hotDogStick.value+' Hot Dog Stick';
    if (document.myForm.hotDogStick.value>1) {
    tmpDescription+='s';
    }
    tmpPrice+=(1*document.myForm.hotDogStick.value*document.myForm.hotDogStickPrice.value);
    }
    if (document.myForm.pieMaker.value>0) {
    tmpDescription+=', '+document.myForm.pieMaker.value+' Mountain Pie Maker';
    if (document.myForm.pieMaker.value>1) {
    tmpDescription+='s';
    }
    tmpPrice+=(1*document.myForm.pieMaker.value*document.myForm.pieMakerPrice.value);
    }
    if (document.myForm.dutchOven.checked==1) {
    tmpDescription+=', Dutch Oven (with Tripod)';
    tmpPrice+=(1*document.myForm.dutchOvenPrice.value);
    }
    if (document.myForm.cookingGrill.checked==1) {
    tmpDescription+=', Cooking Grill Grate';
    tmpPrice+=(1*document.myForm.cookingGrillPrice.value);
    }
    if (document.myForm.propaneLantern.value>0) {
    tmpDescription+='{br}'+document.myForm.propaneLantern.value+' Propane Lantern';
    if (document.myForm.propaneLantern.value>1) {
    tmpDescription+='s';
    }
    tmpPrice+=(1*document.myForm.propaneLantern.value*document.myForm.propaneLanternPrice.value);
    }
    if (document.myForm.batteryLantern.value>0) {
    tmpDescription+=', '+document.myForm.batteryLantern.value+' Battery Lantern';
    if (document.myForm.batteryLantern.value>1) {
    tmpDescription+='s';
    }
    tmpPrice+=(1*document.myForm.batteryLantern.value*document.myForm.batteryLanternPrice.value);
    }
    if (document.myForm.flashLight.value>0) {
    tmpDescription+=', '+document.myForm.flashLight.value+' Flash Light';
    if (document.myForm.flashLight.value>1) {
    tmpDescription+='s';
    }
    tmpPrice+=(1*document.myForm.flashLight.value*document.myForm.flashLightPrice.value);
    }
    if (document.myForm.campChair.value>0) {
    tmpDescription+=', '+document.myForm.campChair.value+' Camp Chair';
    if (document.myForm.campChair.value>1) {
    tmpDescription+='s';
    }
    tmpPrice+=(1*document.myForm.campChair.value*document.myForm.campChairPrice.value);
    }
    if (document.myForm.campToilet.checked==1) {
    tmpDescription+='{br}Camp Toilet';
    tmpPrice+=(1*document.myForm.campToiletPrice.value);
    }
    if (document.myForm.wasteBag.value>0) {
    tmpDescription+=', '+document.myForm.wasteBag.value+' Camp Toilet Waste Bag';
    if (document.myForm.wasteBag.value>1) {
    tmpDescription+='s';
    }
    tmpPrice+=(1*document.myForm.wasteBag.value*document.myForm.wasteBagPrice.value);
    }
    if (document.myForm.campShower.checked==1) {
    tmpDescription+=', Camp Shower Bag w/Shower Head';
    tmpPrice+=(1*document.myForm.campShowerPrice.value);
    }
    if (document.myForm.showerDeck.checked==1) {
    tmpDescription+=', Camp Shower Deck';
    tmpPrice+=(1*document.myForm.showerDeckPrice.value);
    }
    /*
    This stores the built up description to the forms product field to be compatible with
    Mal's cart
    */
    document.myForm.product.value=tmpDescription;
    /*
    This stores the built up price to the forms price field to be compatible with
    Mal's cart
    */
    document.myForm.price.value=(1*tmpPrice*document.myForm.Days.value);
    /*
    This updates the running total value at the bottom of the form so that the user can see
    how much they are spending before sending the data to the form
    */
    document.myForm.runningTotal.value=(1*tmpPrice*document.myForm.Days.value).toFixed(2);
    }
    //]]>
    </script>






    <p>Here's the form, have fun...</p>
    <form action="http://ww12.aitsafe.com/cf/add.cfm"; id="myForm" name="myForm" onsubmit="return submitForm();">
    <input name="return" value="www.malsforms.com/the-most-complex-form-no-cal.html"; type="hidden">
    <input name="userid" value="E9120065" type="hidden">
    <input name="thumb" value="logo.png" type="hidden">
    <input name="product" type="hidden">
    <input name="price" type="hidden">
    <input name="noqty" value="2" type="hidden">
    <input name="qty" value="1" type="hidden">




    <p>Would you like additional padding under your tent?
    <select name="addPadding" onchange="sumFields();" oninput="sumFields();">
    <option value="" selected="selected">No Thanks!</option>
    <option value="Padding 1-2 people:2.00">1-2 people - 2.00</option>
    <option value="Padding 3-4 people:3.00">3-4 people - 3.00</option>
    <option value="Padding 5-6 people:4.00">5-6 people - 4.00</option>
    <option value="Padding 7-8 people:5.00">7-8 people - 5.00</option>
    <option value="Padding 9+ people:6.00">9+ people - 6.00</option>
    </select>
    </p>
    <p>Would you like tent carpet squares?
    <select name="carpetSquares" onchange="sumFields();" oninput="sumFields();">
    <option value="" selected="selected">No Thanks!</option>
    <option value="Carpet squares 1-2 people:3.00">1-2 people - 3.00</option>
    <option value="Carpet squares 3-4 people:4.00">3-4 people - 4.00</option>
    <option value="Carpet squares 5-6 people:5.00">5-6 people - 5.00</option>
    <option value="Carpet squares 7-8 people:6.00">7-8 people - 6.00</option>
    <option value="Carpet squares 9+ people:8.00">9+ people - 8.00</option>
    </select>
    </p>
    <p>Would you like a gazebo (screened in):
    <select name="gazebo" onchange="sumFields();" oninput="sumFields();">
    <option value="" selected="selected">No Thanks!</option>
    <option value="8x8 Gazebo:7.00">8x8 Gazebo - 7.00</option>
    <option value="10x10 Gazebo:8.00">10x10 Gazebo - 8.00</option>
    <option value="12x12 Gazebo:9.00">12x12 Gazebo - 9.00</option>
    </select>
    </p>
    <p>Would you like a canopy (no sides)?
    <select name="canopy" onchange="sumFields();" oninput="sumFields();">
    <option value="" selected="selected">No Thanks!</option>
    <option value="8x8 Canopy:5.00">8x8 Canopy - 5.00</option>
    <option value="10x10 Canopy:6.00">10x10 Canopy - 6.00</option>
    <option value="12x12 Canopy:7.00">12x12 Canopy - 7.00</option>
    </select>
    </p>

    <p class="style2">Current Total: <input name="runningTotal" size="10" maxlength="10" readonly="readonly" class="runningTotal" type="text"></p>
    <p><input value="Add to Mal's Forms cart" type="submit"> <input value="Reset" onclick="document.location.reload(true)" type="button"></p></form><p></p>



    It's a your creation?



    Jul 13 2016 05:43:58

    #4

    GT

    Join date : 2008-09-18      Posts : 3207

    You are digressing... Both Debbie and I have tried to help you, you have not followed Mals instructions or used the script I suggested, my email address is on my contact page (where else)...

    Having trouble with a form or need one building?
    Fast turnaround, but I do charge :)

    Mal's Forms / Scripts and the syntax are here.




    Jul 13 2016 08:00:45

    #5

    Tomele

    Join date : 2016-07-11      Posts : 23

    GT said You are digressing... Both Debbie and I have tried to help you, you have not followed Mals instructions or used the script I suggested, my email address is on my contact page (where else)...

    ------------------------------

    O, now it is, e-mail address on your contact page, yesterday there weren't.I have sent you to email



       «      1   |   2   |   3