Link to home
Start Free TrialLog in
Avatar of lword
lword

asked on

create textbox dynamically when checkbox is checked

i have created a function to form treemenu.how to create a textbox when a particular checkbox of  a levelitem is checked dynamically?

function ShowTree($passjobid,$passjobtitle) //function to display the entire tree with all forms and fields.
{  
    if($passjobid != "")
    {                                                       // Query to fetch the forms in the project
       $queryprojectform = mssql_query("select projectid,levelid,levelname from ProjectForm
                                                  where projectid = '$passjobid' order by orderbyfield");
       $nrowprojectform = mssql_num_rows($queryprojectform);
    }
   
    $queryrepformfield = mssql_query("select levelid,controlid,controlname from ProjectFormFields where projectid =
                               '$passjobid'  and  upper(controlname) <> 'SAVE'  order by controlid ");
    $nrowrepformfield = mssql_num_rows($queryrepformfield);

      for($i=0;$i<$nrowrepformfield;$i++)
    {
      $arrFormField[$i]['levelid'] = mssql_result($queryrepformfield,$i,"levelid");
      $arrFormField[$i]['controlid'] = mssql_result($queryrepformfield,$i,"controlid");
      $arrFormField[$i]['controlname'] = mssql_result($queryrepformfield,$i,"controlname");
    }
   
    $menu01  = new HTML_TreeMenuXL();
      $treeCurLevel[1]=0;  
    $checkboxcount=0;
    for($k=0;$k<$nrowprojectform;$k++)
    {
       $curlevelname = mssql_result($queryprojectform,$k,"levelname");
       $curlevelid = mssql_result($queryprojectform,$k,"levelid");
       $tempcurlevelid =str_replace(".","_",$curlevelid);
       $curid = explode(".",$curlevelid);
       $curnooflinks = sizeof($curid);
       
       if($curnooflinks == 1)//levelid1
       {
         $node001 = new HTML_TreeNodeXL("$passjobtitle");        
         $Level1Address = &$node001->addItem(new HTML_TreeNodeXL("$curlevelname"));
           $LevelAddress = $Level1Address;
         for($i=1;$i<10;$i++)
       {
          $treeCurLevel[$i]=0;
       }
       }
       else
       {                  
        if($treeCurLevel[1] < $curid[1]) //levelid2
          {  
             $Level2Address = &$Level1Address->addItem(new HTML_TreeNodeXL("$curlevelname"));  
             $LevelAddress = $Level2Address;
               $treeCurLevel[1] = $curid[1];
           for($i=2;$i<10;$i++)
           {
             $treeCurLevel[$i]=0;
           }
          }
          else
        {                  
             if($treeCurLevel[2] < $curid[2]) //levelid3
             {      
             $Level3Address = &$Level2Address->addItem(new HTML_TreeNodeXL("$curlevelname"));
             $LevelAddress = $Level3Address;
             $treeCurLevel[2] = $curid[2];
             }
           else
           {
            if($treeCurLevel[3] < $curid[3]) //level4
            {                
               $Level4Address = &$Level3Address->addItem(new HTML_TreeNodeXL("$curlevelname"));
               $LevelAddress = $Level4Address;
               $treeCurLevel[3] = $curid[3];
            }      
            else
            {
              if($treeCurLevel[4] < $curid[4]) //level5
              {
             $Level5Address = &$Level4Address->addItem(new HTML_TreeNodeXL("$curlevelname"));
                 $LevelAddress = $Level5Address;
                 $treeCurLevel[4] = $curid[4];
              }
              else
              {
                 if($treeCurLevel[5] < $curid[5]) //level6
                 {
                $Level6Address = &$Level5Address->addItem(new HTML_TreeNodeXL("$curlevelname"));
                  $LevelAddress = $Level6Address;
                  $treeCurLevel[5] = $curid[5];
                 }
                 else
                 {
                    if($treeCurLevel[6] < $curid[6]) //level7
                    {
                      $Level7Address = &$Level6Address->addItem(new HTML_TreeNodeXL("$curlevelname"));
                    $LevelAddress = $Level7Address;
                    $treeCurLevel[6] = $curid[6];
                    }
                  else
                  {
                      if($treeCurLevel[7] < $curid[7]) //level8
                      {
                        $Level8Address = &$Level7Address->addItem(new HTML_TreeNodeXL("$curlevelname"));
                      $LevelAddress = $Level8Address;
                      $treeCurLevel[7] = $curid[7];
                      }
                    else
                    {
                      if($treeCurLevel[8] < $curid[8]) //level9
                        {
                       $Level9Address = &$Level8Address->addItem(new HTML_TreeNodeXL("$curlevelname"));
                         $LevelAddress = $Level9Address;
                         $treeCurLevel[8] = $curid[8];
                      }
                      }
                    }
                 }
                 }
            }
           }
          }//end if curnooflinks==1
        for($i=0;$i<$nrowrepformfield;$i++)//Code to display the form fields under each form
        {
          if($arrFormField[$i]['levelid']== $curlevelid)
         {      
             $tempcontrolID = $arrFormField[$i]['controlname'].'_ZzAeIoUZz_'.$arrFormField[$i]['controlid'];//concatination
               $tempCtrlName = $arrFormField[$i]['controlname'];
             $tempCtrlNameLen = strlen($tempCtrlName);
             $checkboxcount++;
           $LevelAddress->addItem(new HTML_TreeNodeXL("&nbsp;<input name='rep_$tempcontrolID' type='checkbox' size='1' readonly style='cursor:hand;width:13px;border-width:1px;border-style:flat;font-size:9px;'onclick='Setcheck(1,this,$tempcontrolID);'>&nbsp;<input name='box_$tempcontrolID'class='checkboxes' type='text' size='$tempCtrlNameLen' readonly style='cursor:hand;background:white;border:0px;font-size:10px;' value='$tempCtrlName' onclick='Setcheck(2,this,$tempcontrolID);'>"));}
                         
        }      
       } // end if  
    } // end for
    $menu01->addItem($node001);
    $example1 = &new HTML_TreeMenu_DHTMLXL($menu01, array("images"=>"TMimages","expanded"=>false));
    $example1->printMenu();
            
}//function end
?>
ASKER CERTIFIED SOLUTION
Avatar of Tyzer
Tyzer

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial