Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/229634-javascript-input-button-question/
Share on other sites

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. 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.