|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
gettting values of select options from form
i have a form that has a varied number of select options.
after the form is posted, it goes to a php file. in the php file, in a while loop, i have a $count++ how do i get the value inside $Cm1 or $Cm2 or ... $Cm100 for ($a=0;$a<=100;$a++) { // process } by doing something like $var = $"Cm"."$count"; currently, this only has the value "Cm1" and $$var has the value of "$Cm1" ? // echo "$Cm1 <p> "; // this works // echo "$Cm2 <p>";
__________________
perl / cgi newbie |
|
#2
|
|||
|
|||
|
you could try:
PHP Code:
That should loop through the $_POST array and display only the name and value of the variable that begins with "Cm". I hope this is what you meant. Regards. v. |
|
#3
|
|||
|
|||
|
Have you created the selects as an array in your HTML form?
For example: PHP Code:
If you create the selects as an array in the form, you can access them as you would any other array in PHP. For example: PHP Code:
|
|
#4
|
|||
|
|||
|
for loop
{ echo "<select name=Cm"; echo "$count"; echo "><option>n</option> <option>y</option></select>"; echo "<select name=Cm"; echo "$count"; echo "><option>y</option></select>"; } i need the value in the select object for processing. is it good to make it an array ? |
|
#5
|
||||
|
||||
|
Arrays would be eaiser to use. Just use cm[] rather than a counter for the name. PHP Will automatically make them an array.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages > PHP Development > gettting values of select options from form |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|