Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #7596 > unrolled thread
| Started by | miyotz <miyototz@gmail.com> |
|---|---|
| First post | 2012-11-16 18:02 -0800 |
| Last post | 2012-11-17 07:49 +0000 |
| Articles | 4 — 3 participants |
Back to article view | Back to comp.lang.php
How to add dynamic textbox (row) and save to database using PHP miyotz <miyototz@gmail.com> - 2012-11-16 18:02 -0800
Re: How to add dynamic textbox (row) and save to database using PHP Jerry Stuckle <jstucklex@attglobal.net> - 2012-11-16 22:12 -0500
Re: How to add dynamic textbox (row) and save to database using PHP miyotz <miyototz@gmail.com> - 2012-11-16 22:39 -0800
Re: How to add dynamic textbox (row) and save to database using PHP Denis McMahon <denismfmcmahon@gmail.com> - 2012-11-17 07:49 +0000
| From | miyotz <miyototz@gmail.com> |
|---|---|
| Date | 2012-11-16 18:02 -0800 |
| Subject | How to add dynamic textbox (row) and save to database using PHP |
| Message-ID | <6d48883f-5b7c-463f-acee-4ff94dc26e9f@googlegroups.com> |
Hi. I have here my Javascript code that adds dynamic textbox (row) my problem is how can I save this to database using PHP script? How you can help me guys.. Thanks!
<script type="text/JavaScript">
function addRow(r){
var root = r.parentNode;//the root
var allRows = root.getElementsByTagName('tr');//the rows' collection
var cRow = allRows[0].cloneNode(true)//the clone of the 1st row
var cInp = cRow.getElementsByTagName('input');//the inputs' collection of the 1st row
for(var i=0;i<cInp.length;i++){//changes the inputs' names (indexes the names)
cInp[i].setAttribute('name',cInp[i].getAttribute('name')+'_'+(allRows.length+1))
}
root.appendChild(cRow);
}
function shownames(){
var allInp=document.getElementsByTagName('input');
for(var i=0;i<allInp.length;i++){
alert(allInp[i].name)
}
}
</script>
My HTML code:
<form method= POST> <table width="1024" border="0" cellspacing="6" cellpadding="0"> <tr> <td width="195"><div class="user"><input type="text" name="textfield_a" id="user" tabindex="6"/></div></td> <td width="410"><div class="reported"><input type="text" name="textfield_b" id="reported" tabindex="7"/></div></td> <td width="399"><div class="reported"><input type="text" name="textfield_c" id="reported" tabindex="8"/></div></td> <td width="10"><input name="button" type="button" value="+" onclick="addRow(this.parentNode.parentNode)"></td> </tr> </table> </form>
[toc] | [next] | [standalone]
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Date | 2012-11-16 22:12 -0500 |
| Message-ID | <k86vbt$qid$1@dont-email.me> |
| In reply to | #7596 |
On 11/16/2012 9:02 PM, miyotz wrote:
> Hi. I have here my Javascript code that adds dynamic textbox (row) my problem is how can I save this to database using PHP script? How you can help me guys.. Thanks!
>
> <script type="text/JavaScript">
> function addRow(r){
> var root = r.parentNode;//the root
> var allRows = root.getElementsByTagName('tr');//the rows' collection
> var cRow = allRows[0].cloneNode(true)//the clone of the 1st row
> var cInp = cRow.getElementsByTagName('input');//the inputs' collection of the 1st row
> for(var i=0;i<cInp.length;i++){//changes the inputs' names (indexes the names)
> cInp[i].setAttribute('name',cInp[i].getAttribute('name')+'_'+(allRows.length+1))
> }
> root.appendChild(cRow);
> }
> function shownames(){
> var allInp=document.getElementsByTagName('input');
> for(var i=0;i<allInp.length;i++){
> alert(allInp[i].name)
> }
> }
> </script>
>
> My HTML code:
>
> <form method= POST> <table width="1024" border="0" cellspacing="6" cellpadding="0"> <tr> <td width="195"><div class="user"><input type="text" name="textfield_a" id="user" tabindex="6"/></div></td> <td width="410"><div class="reported"><input type="text" name="textfield_b" id="reported" tabindex="7"/></div></td> <td width="399"><div class="reported"><input type="text" name="textfield_c" id="reported" tabindex="8"/></div></td> <td width="10"><input name="button" type="button" value="+" onclick="addRow(this.parentNode.parentNode)"></td> </tr> </table> </form>
>
Since you are posting the form, the information will be in the $_POST
superglobal. Take a look at the contents of that.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
[toc] | [prev] | [next] | [standalone]
| From | miyotz <miyototz@gmail.com> |
|---|---|
| Date | 2012-11-16 22:39 -0800 |
| Message-ID | <2c54560e-6221-4632-8fe2-4bc29191e53b@googlegroups.com> |
| In reply to | #7597 |
Yes but how can I get the values inserted in each textbox in a row? You see when the user click the "+" button, three textboxes in a row will be added.
[toc] | [prev] | [next] | [standalone]
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Date | 2012-11-17 07:49 +0000 |
| Message-ID | <k87fip$gnb$1@dont-email.me> |
| In reply to | #7598 |
On Fri, 16 Nov 2012 22:39:36 -0800, miyotz wrote: > Yes but how can I get the values inserted in each textbox in a row? You > see when the user click the "+" button, three textboxes in a row will be > added. The content of each correctly named form element will be in the relevant member of the $_POST array. Get it from there. Jerry already told you this. Rgds Denis McMahon
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.php
csiph-web