Sunday 15 June 2014

"selected" in drop down menu using php -


  $ options1 = array (1 = & gt; 'equality', 'a? Is not equal' , 'Greater than', 'â ?? ¥ is greater or equal than', 'at least', 'â ?? ¤ or less',' one contains', ' 'Not included in one'); & Lt; Select Name = "Entry_ID_Sector []" & gt; '; Forex Currency ($ options1 $ i1 => $ opt1): Echo '& lt; Option value = "'. $ I1.' ''. ($ I1 == $ entry_id_selector_topic). '?" Selected ":" "& gt;' $ Opt1. '& Lt; / option & gt; ; What is wrong in this part of the code . ($ I1 =);   $ e1 = = $ Entry_id_selector_topic). "?" The selected ":" "  

The default value is = equal

For example, the user's choice Is more than & gt; , then click on the Post button, reload the page. I hope that the drop down menu is selected The value is displayed & gt; is larger than the hardware, it is the default value.

It has changed to . ($ I1 == $ entry_id_selector_topic) Always select last item from the 'selected' = "selected": "" & gt; '<'> array

in the

not updated Finally get the solution First, it did not understand why $ entry_id_selector_topic [0] does not always display the code from $ options1 .

But when I select some values, click on the drop down menu and click on submit button, $ entry_id_selector_topic = $ _POST ['entry_id_selector']; The only value to be present is the value selected from the drop down menu, then there is a new array with the only object [0] in $ entry_id_selector_topic .

Now it seems that the question is clear.

This code works

  echo & lt; Td> & Lt; Name select name = "entry_id_smith []" onmousedown = "setWidthToAuto this)" & gt; '; Foreach ($ options1 $ i1 => $ opt1): echo '& lt; Option value = "'. $ I1.' '' (($ I1 == $ entry_id_selector_topic [0])? 'Selected': "). '& Gt; $ Opt1. '& Lt; / option & gt;' endforeach; echo & lt; / select & gt; & lt; / td & gt; ';   

Only me There is no explanation $ entry_id_selector_topic [0]

No comments:

Post a Comment