Jump to content

Recommended Posts

hello, i'm actually doing a javascript here to create dynamic textboxes when a button is clicked. now my problem is, how to get all the values from these textboxes and save these values altogether in a column on the table..

 

i know few php coding methods like $_POST in handling values from txtboxes and saving it to database but it doesn't include working with javascript and dynamic textboxes.. and i'm actually doubtful if this is possible..so any help from you guys i would deeply appreciate.

 

heres my code:

<html>
<head>
<script type="text/JavaScript">	
function AddTextBox()
{
document.getElementById('container').innerHTML+='<input type="text" name="block"><br>';	}
</script>
</head>
<body>
<input type="text" name="block">
<div id="container"></div>
<br>
<button onclick="AddTextBox();">Add another textbox</button>
</body>
</html>

The name attribute either needs to be a unique name (so that all the values will be submitted, not just the last one) or you need to use an array name - http://www.php.net/manual/en/faq.html.php#faq.html.arrays

yeah i made a few tests and that's exactly what happened, only the last one got submitted. OK, but i kind of not good in arrays..i get confused. but about the attribute being a unique name, is this like for every <input type="text" name="block"> the name should be different?as in <input type="text" name="block1"><input type="text" name="block2">?

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.