Page 1 of 1

Help with drop down list

Posted: Wed Oct 22, 2008 3:09 am
by littlecoder
Hi Friends,

I want to get the value into '$txt' from an array of hidden fields named 'hd' . I tried the following code...it's not working
for($i=0;$<10;$i++)
{

<input type ="hidden" name="hd $i" value ="$i">

}
$txt = array();
for($i=0;$<10;$i++)
{
$txt[$i] = $_GET['hd'.$i];
echo $txt[$i]."<br>";
}

Any help will be greatly appreciated

Re: Help with drop down list

Posted: Wed Oct 22, 2008 3:16 am
by papa
Mmm, first of all you need to give the hidden fields a proper name, secondly submit the data.

Say you have submitted the fields and returned an array:

Code: Select all

$hd = $_POST['hd'];
 
for($i=0;$i<count($hd);$i++)
{
 
$txt[] = $hd[$i];
 
}
A better way might be to:

Code: Select all

$hd = $_GET['hd'];
 
for($i=0;$i<count($hd);$i++)
{
 
echo $hd[$i]."<br />\n";
 
}
As you have already an array with the same values.

Re: Help with drop down list

Posted: Wed Oct 22, 2008 3:31 am
by requinix

Code: Select all

<input type ="hidden" name="hd[]" value ="$i">
To go with what dad said.

Re: Help with drop down list

Posted: Wed Oct 22, 2008 3:35 am
by aceconcepts
What do you want to do, loop the array values or simply copy the array itself to $txt?

Re: Help with drop down list

Posted: Fri Oct 24, 2008 12:28 am
by littlecoder
Hi ,

It was a problem with my AJAX . Managed to get through it .
Thank you for your suggestions