hi,
i have a serious issue which i am trying to solve but am not able to.
i want to be able to create fields for sections and subsections automatically.
to explain in details i have a field called add section. beside it i hv 2 buttons called add another section and add a subsection.
on clicking add a subsection a subsection is created under the main section.and by clicking on add another section a new section will be created ( ie if the first section was num1 this will create a section number 2)
this can happen n times for each section and subsection.
can some1 help me with this. i know how to create n num of main sections. but the problem is coming when i have to create sub sections for each main section. i am attaching my code with this. any help will be appreciated.
thanks a ton,Code:<?php //storing page to use during redirection after login $frompage = "vieworderslist"; $orderdetails="id='current'"; include("registersessions.php"); //$user = $_SESSION['username_ses']; $user = $username_ses; //redirection if user is not logged in if(trim($user)=="") { header("location:login.php?redurl=$frompage"); } //echo "Ses is $username_ses and user is $user"; $chkfrompage = substr($frompage,0,2); //include connection file include("connection.php"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html > <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link rel="stylesheet" href="js/menu.css"> <title>Employ Me - Creating Feature List</title> <link href="images/styles.css" rel="stylesheet" type="text/css" /> <script type="text/javascript"> var counter = 0; function init1() { document.getElementById('moreFields').onclick = moreFields; moreFields(); } function moreFields() { var limit= 5; counter++; if(counter > limit && limit > 0) { alert ("Cannot add any more modules"); return;} var newFields = document.getElementById('readroot').cloneNode(true); newFields.id = ''; newFields.style.display = 'block'; var newField = newFields.childNodes; for (var i=0;i<newField.length;i++) { var theName = newField[i].name if (theName) newField[i].name = theName + counter; } var insertHere = document.getElementById('writeroot'); insertHere.parentNode.insertBefore(newFields,insertHere); } //document.getElementById('moreFields').onclick = moreFields; window.onload = moreFields; </script> </head> <body leftmargin="2" topmargin="0" marginheight="2" marginwidth="0"> <table width="100%" height="50%" border="0" cellpadding="0" cellspacing="0" bgcolor="#F6F7F2"> <!-- First Row --> <tr> <td><?php include("header.php") ?></td> </tr> <tr> <!-- Second Row End --> <td height="425" valign="top" bgcolor="f6f7f2"><div align="center"> <table width="100%" cellpadding="0" cellspacing="0"> <tr> <td align="center"><span class="bigfnt"> Preparing Feature List </span></td> </tr> </table> <br /> </div> <table width="97%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#D0CDAE" > <tr> <td align="center"> <table width="80%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="21%" class="fields">Select Customer:</td> <td width="79%"><select name="txtdomain" class="menufnt" id="txtcust"> <option value="0" >-Select-</option> <? $sql=mysql_query("select distinct(account_name) from crm_contact"); while($sql_rs=mysql_fetch_object($sql)) {?> <option value="<?=$sql_rs->account_name?>"> <?=$sql_rs->account_name?> </option> <? } ?> </select></td> </tr> <tr><td colspan="2"> </td></tr> <tr> <td valign="top" class="fields">Project Name : </td> <td><input type="text" name="txtproj_name" id="txtproj_name" /><br /></td> </tr> <tr><td colspan="2"> </td></tr> <tr> <td valign="top" class="fields">Scope of Project</td> <td><textarea name="txtproj_scope" id="txtproj_scope" rows="10" cols="50" ></textarea></td> </tr> <tr><td colspan="2"> </td></tr> <tr> <td colspan="2"><div id="readroot" style="display: none; padding-top:5px;"><span class="fields" style="padding-right:70px;">Add a Main Section:</span><input type="text" name="txtmainsection" id="txtmainsection" /><input name="moreFields" type="button" id="moreFields" onclick="init1();" value="Add another Section" /></div> <span id="writeroot"></span> </td> </tr> <tr><td colspan="2"> </td> </tr> <tr> <td class="fields"> </td> <td> </td> </tr> <tr><td colspan="2"> </td></tr> <tr> <td class="fields"> </td> <td> </td> </tr> <tr><td colspan="2"> </td></tr> <tr> <td class="fields"> </td> <td> </td> </tr> </table> </td> </tr> </table></td></tr> <tr> <td height="15" valign="top" bgcolor="f6f7f2"><?php include("footer.php") ?></td> </tr> </table> </body> </html>
Suk



Reply With Quote
Bookmarks