Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

create textbox dynamically when checkbox is checked

Posted on 2004-11-17
3
Medium Priority
?
1,221 Views
Last Modified: 2008-01-09
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
?>
0
Comment
Question by:lword
1 Comment
 
LVL 3

Accepted Solution

by:
Tyzer earned 2000 total points
ID: 12604542
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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question