|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
option value
hello,
if am using an arrays in my code, i modify my form fields(text box, check box) like this, $cnt = count($HTTP_POST_VARS['id']); for($cntr=0;$cntr<$cnt;$cntr++) { <input type="text" name="ac[<?=$counter?>]" value="<?=$ac?>"> if (!$HTTP_POST_VARS['attach'][$cntr]) $attach=0; else $attach=1; <input type="checkbox" name="is_enrolled[<?=$counter?>]" value="1"<? if ($isenrolled==1)echo "checked";?>> BUT, how is with option box. If it is like this for example, <SELECT size=1 name=brand> <OPTION value ="0"<?php if($brand==0){ echo 'selected'; }?>>NIKE</OPTION> <OPTION value ="1"<?php if($brand==1){ echo 'selected'; }?>>ADDIDAS</OPTION></SELECT> Now, my question is , how can i modify the above option code with respect to an array. could some body pls make the changes and present it to me. many thanks |
|
#2
|
|||
|
|||
|
RE: option value
i don't even really get how your first array is working.. either way you could use the same code to determin your values but an option box can only have one item at a time selected.
|
|
#3
|
|||
|
|||
|
RE: option value
OK, let me try to explain in detail:
<? Database connection if ($HTTP_POST_VARS){ $cnt = count($HTTP_POST_VARS['id']); for($cntr=0;$cntr<$cnt;$cntr++) { if (!$HTTP_POST_VARS['attach'][$cntr]) $attach=0; else $attach=1; UPDATE Statement; } } SELECT STATEMENT ?> Field headings <?php $counter=0; $old_values=null; while statement to get the fields ?> //here comes my form fields <td width="154" height="23"> <input type="text" name="tei[<?=$counter?>]" value="<?=$tei?>"> </td> <td width="69" height="23"> <input type="checkbox" name="attach[<?=$counter?>]" value="1"<? if ($attach==1)echo "checked";?>> <?php $old_values.=' <input type="hidden" name="id['.$counter.']" value="'.$row->HS_ID.'"> '; $counter++; } ?> </table> <?=$old_values?> hmm..thatz it.this works fine so far with all my text boxes and check boxes. My problem is only with OPTION VALUE. If i have a code like this for my selectable field, <SELECT size=1 name=type> <OPTION value ="0"<?php if($type==0){ echo 'selected'; }?>>Addidas</OPTION> <OPTION value ="1"<?php if($type==1){ echo 'selected'; }?>>GAP</OPTION></SELECT> How should i make the changes with respect to my array? Hope somebody would be there to help me. thanks once again. |
|
#4
|
|||
|
|||
|
RE: option value
Do you want to geneder the options from an array??
Then, try this: |
![]() |
| Viewing: Codewalkers Forums > PHP Related > PHP Coding > option value |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|