Jump to content

pass dynamic text from html in javascript to php?


unknown00

Recommended Posts

not sure what section to post this in, basically i have html in a javascript function that i want to pass into a php.

 

here is some of my javascript code

				
var names = document.getElementById('names').value;
var nms = names.split(";;")
for (i=0; i<las.length; i++)
{
var contentString = [
'<div id="tab-1">',
'<p><h1>'+nms[i]+'</h1></p>',
'</div>'
+'<form action="index.php" method="post" enctype="multipart/form-data">'+
'<input id="delbutton" name="delbutton" type="submit" value="Delete">',+'</form>'
}

then when the button gets pressed it goes to

	if(isset($_POST['delbutton'])=='Delete')
{
	echo("into the php delete: " . $_POST['name2'] . "<br />\n");
	echo '<pre>' . print_r($_POST,true) . '</pre>';
}

 

basically i want to be able to access the value of nms in the php call. i am able to pass anything in <input> tags like normal html, but i want to get nms to go through

 

what should i do?

Link to comment
Share on other sites

+'<form action="index.php?nms='+nms[$i]+'" method="post" enctype="multipart/form-data">'+

then on your php:

if(isset($_POST['delbutton'])=='Delete')
{
	echo("into the php delete: " . $_POST['name2'] . "<br />\n");
	echo '<pre>' . print_r($_POST,true) . '</pre>';
                echo $_GET[''nms];
}

Link to comment
Share on other sites

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.