473,598 Members | 3,252 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Get cell and textbox values from a html table when the textboxes have same names

GD
Hi,

I am trying to get values from table cells and textboxes that have same
component names in a table after posting to the same page. Javascript is
able to get the component values while the components have same names. For
example:

for (var i=0; i < document.FormTe st.txtTest.leng th; i++)
{
alert(document. FormTest.txtTes t[i].value);
}

How to do it using PHP? The following is the test code:
-------------------------------------------------------
<html>
<head<title>Tes t</title></head>

//try to get values after posting
<?php
$textboxValue = $_POST['txtTest'];
echo $textboxValue;
?>

<body bgcolor="#ebeaf f" >
<form name="FormTest" id="FormTest" action="test.ph p" method="post" >

<?php
echo "<table>";
for ($counter = 0; $counter <= 3; $counter++)
{
echo "<tr><td><i nput type='text' name='txtTest'> </td><td>cell
value</td></tr>";
}
echo "</table>";
?>

</form>
</html>
-----------------------------------------------

Thanks.

GD
Apr 1 '07 #1
2 4635
GD kirjoitti:
Hi,

I am trying to get values from table cells and textboxes that have same
component names in a table after posting to the same page. Javascript is
able to get the component values while the components have same names. For
example:

for (var i=0; i < document.FormTe st.txtTest.leng th; i++)
{
alert(document. FormTest.txtTes t[i].value);
}

How to do it using PHP? The following is the test code:
-------------------------------------------------------
<html>
<head<title>Tes t</title></head>

//try to get values after posting
<?php
$textboxValue = $_POST['txtTest'];
echo $textboxValue;
?>

<body bgcolor="#ebeaf f" >
<form name="FormTest" id="FormTest" action="test.ph p" method="post" >

<?php
echo "<table>";
for ($counter = 0; $counter <= 3; $counter++)
{
echo "<tr><td><i nput type='text' name='txtTest'> </td><td>cell
value</td></tr>";
}
echo "</table>";
?>

</form>
</html>
-----------------------------------------------
Add [] to the field names so that php makes an array of them:
<input type='text' name='txtTest[]'>

Then you can access them thru $_POST['txtTest'][0] etc...

--
Ra*********@gma il.com
"Olemme apinoiden planeetalla."
Apr 1 '07 #2
GD
It works great. Thanks!

GD

"Rami Elomaa" <ra*********@gm ail.comwrote in message
news:eu******** **@nyytiset.pp. htv.fi...
GD kirjoitti:
>Hi,

I am trying to get values from table cells and textboxes that have same
component names in a table after posting to the same page. Javascript is
able to get the component values while the components have same names.
For
example:

for (var i=0; i < document.FormTe st.txtTest.leng th; i++)
{
alert(document. FormTest.txtTes t[i].value);
}

How to do it using PHP? The following is the test code:
-------------------------------------------------------
<html>
<head<title>Te st</title></head>

//try to get values after posting
<?php
$textboxValu e = $_POST['txtTest'];
echo $textboxValue;
?>

<body bgcolor="#ebeaf f" >
<form name="FormTest" id="FormTest" action="test.ph p" method="post" >

<?php
echo "<table>";
for ($counter = 0; $counter <= 3; $counter++)
{
echo "<tr><td><i nput type='text' name='txtTest'> </td><td>cell
value</td></tr>";
}
echo "</table>";
?>

</form>
</html>
-----------------------------------------------

Add [] to the field names so that php makes an array of them:
<input type='text' name='txtTest[]'>

Then you can access them thru $_POST['txtTest'][0] etc...

--
Ra*********@gma il.com
"Olemme apinoiden planeetalla."

Apr 1 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2827
by: Steve B. | last post by:
I have a DataGrid on the left and TextBoxes (TB) on the right. The TB's reflect the contents of the grid cells. Sorting of columns (both thru VS and programmatically) work fine except, when the form/grid first opens up and the grid is immediately sorted the TB don't reflect the sorted data of the First row of the grid. Note: Initially the black grid indicator arrow points to the first row. If the user choses another row and then sorts...
2
4810
by: Alpha | last post by:
Hi, I have a window based program. One of the form has several textboxes and a datagrid. The textboxes are bind to the same dataset table as the datagrid and the text changes to reflect different row selected in the datagrid. I want to save the changes that user make in the textboxes when they select a different row in the datagrid. I tried capturing the textbox.text at datagrid's CurrentCellChanged event but by then the textbox.text...
6
1782
by: tshad | last post by:
I have a cell with 2 items in it: a textbox and a link. The link is actually a button (image), but for the example I am using a link, which is doing the same thing. Here is the stripped down version of my page that shows the problem: *********************************************************************************** <html> <head></head>
8
3461
by: tshad | last post by:
I cannot seem to get the asp:textbox to use classes. Style works fine. I am trying to set the textbox to act like a label in some instance so it doesn't have a border, readonly and the background is grey. I have a class set as: ..table2Label{ border-style:none; background-color:#F6F6F6; }
2
1215
by: gmalai | last post by:
Hi, I would like to know if it is possible to add a text box in table cell if I **double-click** in that particular table cell(the table was generated at runtime). If so, could you please give some helpful hints as to how to proceed. Thanks, Gayathri
7
3098
by: Arne Beruldsen | last post by:
in vbnet2005 I have a datagridview. When the user clicks on a row...I would like the contents of certain cells to populate a textbox. To do this...i need to be able to refer to the row and colums...something like textbox = contents (rx, cx) How can I refer to the cell contents? Thanks....
0
2390
by: Jacob Donajkowski | last post by:
Once the user logs in I want to have the users switch from the Roster View to the Profile View and enter their profile infomation and save it. Then the next time they login and go to the Profile View I want the form populated from there profile on the sql server. The code to save the profile works fine. But when the user logs back in they data doesn't load back to the form. The multiview is located inside the LoginView's Logged-In View ....
1
9349
by: colleen1980 | last post by:
Hi: Can any one please tell me that how to i pass the two textbox values in the new page. If i use the form action in the popup window page then the new page is open in the same popup window as i need to open the new page in the main page window with passing the two textbox parameters into the new page. Program opens the new page but dont know how to pass the two textboxes values into the new page name deceasedToday.asp Needs help in...
1
2114
by: Kageoni2 | last post by:
I'm trying to add new records to my database using 4 textboxes, one for each field in my databases table. I've got ID, Firstname, Surname and Course. But I can't figure out at all how to link whats Inputted into the textboxes to be added as a new record to my database when the "Insert Record" button is pushed.., i've spent nearly 2 hours searching the internet for tutorials and people asking similar questions but I can't find anything that...
0
7899
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8392
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8397
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8050
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6718
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5438
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3939
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1504
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1250
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.