By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,740 Members | 844 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,740 IT Pros & Developers. It's quick & easy.

how do i pass control(text field) values from one html to other using hidden variables.

P: n/a

function submitPartsForm(str) {

var count=document.getElementsByName("partId");
for(var i=0;i<count.length;i++)
{

document.mylist.myNum[i].value= document.getElementsByName("partNum")
(i).value;

}

document.forms["mylist"].submit();
}
myNum[] is a hidden variable and partNum is the name of a text field
that has many instances i mean there are many textfields with the same
name so it forms a column in a data table.

Mar 7 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
pr***********@gmail.com wrote:
>
function submitPartsForm(str) {

var count=document.getElementsByName("partId");
for(var i=0;i<count.length;i++)
{

document.mylist.myNum[i].value= document.getElementsByName("partNum")
(i).value;

}

document.forms["mylist"].submit();
}
myNum[] is a hidden variable and partNum is the name of a text field
that has many instances i mean there are many textfields with the same
name so it forms a column in a data table.
Why not give each each textfield a unique name?
I cannot think of one good reason...

Regards,
Erwin Moller

Mar 7 '07 #2

P: n/a
On Mar 7, 12:14 pm, Erwin Moller
<since_humans_read_this_I_am_spammed_too_m...@spam yourself.comwrote:
prabodhtiw...@gmail.com wrote:
function submitPartsForm(str) {
var count=document.getElementsByName("partId");
for(var i=0;i<count.length;i++)
{
document.mylist.myNum[i].value= document.getElementsByName("partNum")
(i).value;
}
document.forms["mylist"].submit();
}
myNum[] is a hidden variable and partNum is the name of a text field
that has many instances i mean there are many textfields with the same
name so it forms a column in a data table.

Why not give each each textfield a unique name?
I cannot think of one good reason...

Regards,
Erwin Moller
Try naming them as follows:
<input name="partnum[]" ...>
In PHP, these are automatically converted into an array inside your
protocol-dependent superglobal (_GET or _POST), so you can use them at
will, although, if this is a static html, why not really give them all
unique names, as Erwin suggested.

Mar 7 '07 #3

P: n/a
On Wed, 07 Mar 2007 11:00:16 +0100, <pr***********@gmail.comwrote:
>
function submitPartsForm(str) {

var count=document.getElementsByName("partId");
for(var i=0;i<count.length;i++)
{

document.mylist.myNum[i].value= document.getElementsByName("partNum")
(i).value;

}

document.forms["mylist"].submit();
}
myNum[] is a hidden variable and partNum is the name of a text field
that has many instances i mean there are many textfields with the same
name so it forms a column in a data table.
One way would be to join the text values together using a join character
unlikely to appear in the texts, like so:

function submitPartsForm() {
var theNodeList = document.getElementsByName("partId");
var theNodeValues = document.forms["myList"].elements["theNodeValues"];
if(theNodeList&&theNodeValues) {
for (var i=0;i<theNodeList.length;i++) {
if (theNodeList[i].value) {
theNodeValues.value += ("|" + theNodeList[i].value.toString());
}
}
document.forms["myList"].submit();
}
}

(Above script assumes the form has a hidden input (not disabled), named
"theNodeValues".)

Then in your server-side script you can use whatever method your language
uses to split the string into parts using the "|" as a split character.
Usually this results in an array.

--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Mar 11 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.