Javascript Not Adding

I have the following script that grabs a input field value:
<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 }

Open in new window

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"

Open in new window


What else do I need to supply so you can help me solve thbis issue?
LVL 7
rgranlundAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GaryCommented:
Are you sure myBox8 = 'yes' exactly?
What happens if you add an alert for myBox8? Does it alert yes
0
mervintCommented:
Is association-membership-1  a variable? Then move it outside the quotes
0
rgranlundAuthor Commented:
Yes, myBox8 alerts 'yes'.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

GaryCommented:
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/
0
rgranlundAuthor Commented:
<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>

Open in new window

0
GaryCommented:
Your code and I still get 0.9

http://jsfiddle.net/GaryC123/3tqs77m4/3/
0
rgranlundAuthor Commented:
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/
0
GaryCommented:
Change
var myBox8 = document.getElementById('addon-28-bicycle-info[association-membership]').value;

Open in new window

to
var myBox8 = jQuery('[id*="association-membership"]').val()

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rgranlundAuthor Commented:
Still no go.  Thanks for all of your help.  I don't want to waste your time with my mess.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.