close ad
Install the LAtest Updates to Work with CC 2017 and CC 2018
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

With JavaScript if else multi conditional statement to incorporate values from 2 different menus to affect the price? This is part of a much larger form that I've been working on.

Thread began 9/12/2013 2:57 pm by tdhkfinkel424121 | Last modified 9/12/2013 4:15 pm by tdhkfinkel424121 | 699 views | 1 replies

tdhkfinkel424121

With JavaScript if else multi conditional statement to incorporate values from 2 different menus to affect the price? This is part of a much larger form that I've been working on.

Hi,
I've had some help from your techs. but now I'm stuck again, I hope you can help me...
I'm trying to get the 'unitPrice' of the form to be affected by the values selected in 2 selection menus. But at the moment the form doesn't do anything.
Basically depending on the values selected in the menus Boat_Type and select1(storage type) the unit price needs to change and then be multiplied by the quantity to get the total.

Here's what I have in Javascript & the html:
<script language="javascript" type="text/javascript" />

function process3Shirts()
{
var boatType = new Array();
boat_type["Power"]= 'Power';
boat_type["Sail"] = 'Sail';

var storageType = new Array();
storage_type["Dry"]= 'Dry';
storage_type["Wet"] = 'Wet';

var boatType = "";
var theForm = document.forms["HSMLicenseForm_BrassyHSM_HSM"];
var selectedBoatType = theForm.elements["Boat_Type"];

boatType = boat_type[selectedBoatType.value];

var storageType = "";
var selectedStorageType = theForm.elements["select1"];

storageType = storage_type[selectedStorageType.value];

unitPrice= boatType && storageType;
var boatType = (document.HSMLicenseForm_BrassyHSM_HSM.Boat_Type.value);
var storageType = (document.HSMLicenseForm_BrassyHSM_HSM.select1.value);
//var quantity = parseInt(document.HSMLicenseForm_BrassyHSM_HSM.txt3ShirtQuantity.value);
var unitPrice = parseFloat(document.HSMLicenseForm_BrassyHSM_HSM.txt3ShirtUnitPrice.value);
//var total = unitPrice * quantity;

if(storageType == 'Dry' && boatType == 'Power'){
unitPrice = 50.00;
total = unitPrice * quantity;

}else if(storageType == 'Dry' && boatType == 'Sail'){
unitPrice = 55.00;
total = unitPrice * quantity;

}else if(storageType == 'Wet' && boatType == 'Sail','Power'){
unitPrice = 37.00;
total = unitPrice * quantity;
}
var total = unitPrice * quantity;
document.HSMLicenseForm_BrassyHSM_HSM.txt3ShirtTotal.value = total.toFixed(2);
document.getElementById("txt3ShirtUnitPrice_show").innerHTML = unitPrice.toFixed(2) + (" /ft");
document.getElementById("txt3ShirtTotal_show").innerHTML = total.toFixed(2);
}

</script>

<html>
<div class="lineGroup">
<div class="columnGroup">
<label for="Boat_Type" class="sublabel" > Boat Type<span class="requiredIndicator">&nbsp;*:</span></label>
<div class="errorGroup">
<div class="fieldPair">
<div class="fieldGroup"> <span id="Boat_Type_Spry"> <span>
<select class="formMenufield_Medium" name="Boat_Type" select id="Boat_Type" tabindex="21" onChange="hideServerError('Boat_Type_ServerError');">
<option value="" <?php if (!(strcmp("", (isset($_GET["invalid"])?ValidatedField("licenseform","Boat_Type"):"")))) {echo "selected=\"selected\"";} ?>>Select</option>
<option value="Power" <?php if (!(strcmp("Power", (isset($_GET["invalid"])?ValidatedField("licenseform","Boat_Type"):"")))) {echo "selected=\"selected\"";} ?>>Power</option>
<option value="Sail" <?php if (!(strcmp("Sail", (isset($_GET["invalid"])?ValidatedField("licenseform","Boat_Type"):"")))) {echo "selected=\"selected\"";} ?>>Sail</option>
</select>
<span class="selectRequiredMsg">Please select the type of boat you have.</span> </span> </span>
<?php
if (ValidatedField('licenseform','licenseform')) {
if ((strpos((",".ValidatedField("licenseform","licenseform").","), "," . "21" . ",") !== false || "21" == "")) {
if (!(false)) {
?>
<span class="serverInvalidState" id="Boat_Type_ServerError">Please select the type of boat you have.</span>
<?php //WAFV_Conditional license_form.php licenseform(21:)
}
}
}?>
</div>
</div>
</div>
</div>
<table border="0" width="761">
<tr>
<td width="221"><label for="WINTER_LOA_Boat" class="sublabel" ><strong>Winter Storage:</strong> <br>
Nov. 1- April 30</label></td>
<td width="167"><span id="WINTER_LOA_Boat_Spry"><span class="style59">*</span>
<input id="txt3ShirtQuantity" input name="txt3ShirtQuantity" type="text" class="formTextfield_XSmall" value="<?php echo((isset($_GET["invalid"])?ValidatedField("licenseform","txt3ShirtQuantity"):"")); ?>" size="4" tabindex="46"placeholder="00" onkeyup="process3Shirts();hideServerError('txt3ShirtQuantity_ServerError');" onBlur="process3Shirts();hideServerError('txt3ShirtQuantity_ServerError');">
Ft. LOA<span class="textfieldInvalidFormatMsg">Invalid format. Please enter the overall length of your boat.</span><span class="textfieldMinValueMsg">The entered value is less than required. You need at least 2 digets.</span><span class="textfieldMaxValueMsg">The entered value is greater than allowed .</span><span class="textfieldMinCharsMsg">Minimum number of characters not met. </span><span class="textfieldMaxCharsMsg">Exceeded maximum number of characters.</span><span class="textfieldRequiredMsg">Please enter the overall length of your boat.</span></span>
<?php
if (ValidatedField('licenseform','licenseform')) {
if ((strpos((",".ValidatedField("licenseform","licenseform").","), "," . "46" . ",") !== false || "46" == "")) {
if (!(false)) {
?>
<span class="serverInvalidState" id="txt3ShirtQuantity_ServerError">Please enter the overall length of your boat.</span>
<?php //WAFV_Conditional license_form.php licenseform(46:)
}
}
}?></td>
<td width="145"><span class="style59">*</span>$<span class="txt3ShirtUnitPrice" id="txt3ShirtUnitPrice_show">0.00</span><span class="txt3ShirtUnitPrice" id="txt3ShirtUnitPrice_show"></span>
<input id="txt3ShirtUnitPrice" input name="txt3ShirtUnitPrice" type="hidden" class="formTextfield_XSmall" value="<?php echo((isset($_GET["invalid"])?ValidatedField("licenseform","txt3ShirtUnitPrice"):"")); ?>" size="11" tabindex="47" onBlur="hideServerError('txt3ShirtUnitPrice_ServerError');">

/ft </td>
<!-- <td width="77"><input name="btn3Shirts" type="button" onClick="process3Shirts()" value="Calc. Total" tabindex="48"></td>-->
<td width="119">Total $<span class="txt3ShirtTotal" id="txt3ShirtTotal_show">0.00</span><span class="txt3ShirtTotal" id="txt3ShirtTotal_show"></span>
<input name="txt3ShirtTotal" type="hidden" class="formTextfield_XSmall" value="0.00" size="8" tabindex="49"></td>
</tr>
<tr>
<td colspan="2" align="left"><div class="errorGroup">
<div class="fieldPair">
<label for="Storage_Type"><span class="requiredIndicator">*</span>Storage Type&nbsp;</label>
<span id="spryselect_storage_type">
<label for="select1"></label>
<select class="formMenufield_Medium" name="select1" id="select1" tabindex="50" onChange="hideServerError('Engine_Type_ServerError');">
<option value="" <?php if (!(strcmp("", (isset($_GET["invalid"])?ValidatedField("licenseform","select1"):"")))) {echo "selected=\"selected\"";} ?>>Select</option>
<option value="Dry">Dry</option>
<option value="Wet">Wet</option>
<!-- <option value="N/A">N/A</option>-->
</select>
<span class="selectRequiredMsg">Please select a storage type.</span></span>
<?php
if (ValidatedField('licenseform','licenseform')) {
if ((strpos((",".ValidatedField("licenseform","licenseform").","), "," . "50" . ",") !== false || "50" == "")) {
if (!(false)) {
?>
<span class="serverInvalidState" id="select1_ServerError">Please select a storage type.</span>
<?php //WAFV_Conditional license_form.php licenseform(50:)
}
}
}?> </div>
</div></td>
<td >
</td>
</tr>
</table>

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...