A
A
Alexander Ivanov2016-07-19 13:33:33
PHP
Alexander Ivanov, 2016-07-19 13:33:33

How to select a checked attribute in a while loop?

while($arEnum = $UF_TIP_COMPANY->GetNext()){
          echo "<label><input type='checkbox' value='".$arEnum["ID"]."' name='UF_TIP_COMPANY[]'";
if(key($UF_TIP_COMPANY->GetNext())){ echo "checked";}
          echo">".$arEnum["VALUE"]."</label><br />";
        }

So it displays only the selected ones, but how to implement something to display everything?
Example
https://dev.1c-bitrix.ru/api_help/main/reference/c... It
remains just to remove duplicates
<? 
          while($arEnum = $UF_TIP_COMPANY->GetNext()){
            foreach($ppi as $key=>$value){
              //echo $arEnum['ID']."=>".$value."<br />";
              echo "<label><input type='checkbox' value='".$arEnum["ID"]."' ";
              if($arEnum["ID"]==$value){
                echo "checked";
              }
              echo " name='UF_TIP_COMPANY[]' />".$arEnum["VALUE"]."</label><br />";
            }
          }
        ?>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Emelyanov, 2016-07-19
@babarun

The brain exploded.
"He" is who? Loop or GetNext method?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question