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?

+'<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];
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.