Robert Granlund
asked on
Javascript Not Adding
I have the following script that grabs a input field value:
What else do I need to supply so you can help me solve thbis issue?
<script>
var myBox8 = document.getElementById('addon-28-bicycle-info[association-membership-1]').value;
<?php
$assoc = $pdo->prepare($association);
try {
$assoc->execute();
$ass = $assoc->fetchAll();
foreach ($ass as $as) {
$app = $as->physical_damage;
}
}
catch(PDOException $b) {
echo 'ERROR: ' . $b->getMessage();
}
?>
if(myBox8 == 'yes' ) { myBox9 = <?php echo $app; ?> }
else { myBox9 = 1 }
When it renders it looks like this:var myBox8 = document.getElementById('addon-28-bicycle-info[association-membership-1]').value;
if(myBox8 == 'yes' ) { myBox9 = 0.90 }
else { myBox9 = 1 }
Then I have:
var myResult = parseFloat(myResultSub) * parseFloat(myBox9);
myBox9 always uses 1 even though the value of myBox8 is "yes"
What else do I need to supply so you can help me solve thbis issue?
Is association-membership-1 a variable? Then move it outside the quotes
ASKER
Yes, myBox8 alerts 'yes'.
Can you post the rendered HTML of the addon-28-bicycle-info element - is this something the user enters or is already filled in
Here's your code exactly as you have it and it alerts 0.9
http://jsfiddle.net/GaryC123/3tqs77m4/2/
Here's your code exactly as you have it and it alerts 0.9
http://jsfiddle.net/GaryC123/3tqs77m4/2/
ASKER
<select name="addon-28-bicycle-info[association-membership-1]" id="addon-28-bicycle-info[association-membership-1]" onchange="findSum()" >
<option>Association Membership</option>
<option value="yes">Yes</option>
<option value="no">No</option>
ASKER
If you go here, and go through the process and pay attention to association membership and then hit add to cart, you see it does not stick:
http://spokeinsurance.com/index/
http://spokeinsurance.com/index/
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Still no go. Thanks for all of your help. I don't want to waste your time with my mess.
What happens if you add an alert for myBox8? Does it alert yes