troubleshooting Question

php and Javascript Help

Avatar of easyrider439
easyrider439 asked on
13 Comments3 Solutions474 ViewsLast Modified:
Hey Experts, How can I get that php to work in this JavaScript script that I wrote. To my understanding php is executed during loading and variables are loaded into the browser cant I take that php variable and make it a JavaScript variable or How would That work? Hope that makes sense.

in my code I have a php variable echoed and it doesnt work what can I do?
function addRow(divname) {
    var totalrows = document.getElementById(divname).rows.length-2;
    var newdiv = document.createElement('tr');
    var products = '<?php echo $products; ?>';    
    newdiv.innerHTML = '<td>' + (totalrows + 1) + '</td>';
    newdiv.innerHTML += '<td>' + products + '</td>';

Open in new window


Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 3 Answers and 13 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 3 Answers and 13 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros