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
?>
lwordAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TyzerCommented:
This is the way you can create html elements dynamicly
<script>
      function fnCreateTextBox(){
            var oTextbox = document.createElement('INPUT');
            var oParent = document.getElementById('row1col2')
            oTextbox.setAttribute('type','text');
            oParent.appendChild(oTextbox);            
      }
</script>
<table><tr>
      <td id=row1col1><input type=checkbox id=mycheckbox onclick="javascript:fnCreateTextBox()"></td>
      <td id=row1col2></td>
</tr></table>

Hope this helps you ..
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.