Applellial Posted March 5, 2011 Share Posted March 5, 2011 Hi guys, I'm trying to add a php string to some javascript: document.getElementById("button").value = mygetrequest.responseText; basically there are a load of buttons on one page. So i need to add a value at the end of button. Basically the ID of each row so button<? echo $row['ID']; ?> but i'm not too sure how i would do this in javascript. Any help Thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/229634-javascript-input-button-question/ Share on other sites More sharing options...
jcanker Posted March 5, 2011 Share Posted March 5, 2011 It's not terribly clear what you're trying to do, exactly. Do you need to get values from a php script and use them in the javascript, or are you just trying to use dynamic variables? If you just need dynamically named buttons on the form, just create an i counter and tack that on to the end for each button and then have the php run through the $_POST array. If you're trying to have them named based on info returned from a php script, that's an entirely different animal. That's what AJAX is all about. You can't intermingle your php variables/values, but you can get data from a php script and parse it into the javascript--just use the same variable name and assign the value returned from the AJAX script. Quote Link to comment https://forums.phpfreaks.com/topic/229634-javascript-input-button-question/#findComment-1183148 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.