Jump to content

[SOLVED] Only arrayname[0] value gets passed


elabuwa

Recommended Posts

Hi guys, I have a page that allows the user to add textbox when a button is clicked.

 

Adding a textbox with a button click is working fine.

<TD width="144"><INPUT type="text" name="debit[]"/></TD>

 

I have named it as debit[] because it believe the user will enter 2 or more values.

 

the problem is only the first text box value gets passed through to the next page.

 

the code to getting the array value in the next page is

 

$txtbox = $_POST['debit'];

 

while (list($a, $b) = each($txtbox)) {

    echo "Key: $a; Value: $b<br />\n";

}

 

AND i tried this

 

foreach ($txtbox as $key => $value) {

    echo "Key: $key; Value: $value<br />\n";

}

 

 

And I tried this

 

echo $txtbox[0];

echo $txtbox[1];

 

What ever I try only the first array index value gets displayed.

 

can you guys please help me out.

 

below is the code for adding rows. just thought you might like to have a look at it.

 

<SCRIPT language="javascript">

        function addRow(tableID) {

 

            var table = document.getElementById(tableID);

 

            var rowCount = table.rows.length;

            var row = table.insertRow(rowCount);

 

            var colCount = table.rows[0].cells.length;

 

            for(var i=0; i<colCount; i++) {

 

                var newcell = row.insertCell(i);

 

                newcell.innerHTML = table.rows[0].cells.innerHTML;

                //alert(newcell.childNodes);

                switch(newcell.childNodes[0].type) {

                    case "text":

                            newcell.childNodes[0].value = "";

                            break;

                    case "checkbox":

                            newcell.childNodes[0].checked = false;

                            break;

                    case "select-one":

                            newcell.childNodes[0].selectedIndex = 0;

                            break;

                }

            }

        }

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.