Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jul 2011
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    pass dynamic text from html in javascript to php?

    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
    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
    Code:
    	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[i] in the php call. i am able to pass anything in <input> tags like normal html, but i want to get nms[i] to go through

    what should i do?

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,853
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    if(isset($_POST['delbutton'])=='Delete')
    That should be just
    PHP Code:
    if(isset($_POST['delbutton'])) 
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •