Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > how do i pass control(text field) values from one html to other using hidden variables.

Reply
Thread Tools

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

 
 
prabodhtiwari@gmail.com
Guest
Posts: n/a
 
      03-07-2007

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.

 
Reply With Quote
 
 
 
 
Erwin Moller
Guest
Posts: n/a
 
      03-07-2007
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

 
Reply With Quote
 
 
 
 
Darko
Guest
Posts: n/a
 
      03-07-2007
On Mar 7, 12:14 pm, Erwin Moller
<since_humans_read_this_I_am_spammed_too_m...@spam yourself.com> wrote:
> 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.

 
Reply With Quote
 
OmegaJunior
Guest
Posts: n/a
 
      03-11-2007
On Wed, 07 Mar 2007 11:00:16 +0100, <> 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.
>


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/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Re: How to pass one HTML values to another HTML Gabriel Genellina Python 0 04-02-2009 07:48 AM
Pass 3 text values from one webpage to other Sharon ASP .Net 3 11-23-2006 10:30 PM
Re: sending hidden values AND option values at the same time ? Jukka K. Korpela HTML 1 09-12-2006 02:32 PM
Pass hidden values in ASP VK ASP General 8 12-22-2003 02:40 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57