php - Is there a limit on the amount of JavaScript Files on your head? -
i'm asking because every time use second javascript code gets buggy. @ first js file 1 , trying make work both select tags i'm working with. wasn't able implement it. called quiets , copied renamed avoid conflicts in name. errors keep on happening. maybe there's wrong code or?
html head
<head> <title>packages</title> <link rel="icon" type="image/ico" href="../favicon.ico"/> <link rel="stylesheet" type="text/css" href="../style/style_p.css"/> <script type="text/javascript" src="../style/add_fields.js"></script> <script type="text/javascript" src="../style/addmorefields.js"></script> <h1><img src="../images/logo.png" alt="logo"></h1> </head> js 1
var instance = 0; function morefields(parenthome, clonehome) { // check if there isn't more 3 fields if(instance != 3) { instance++; // create child var tempclone = document.getelementbyid(parenthome).clonenode(true); // remove templet clone's id avoid future confusion tempclone.id = ""; tempclone.style.display = 'block'; /* cloned templet's * children. here make * ones have name * unique. */ var clonec = tempclone.childnodes; for(var = 0; < clonec.length; i++) { var childname = clonec[i].name; if(childname) clonec[i].name = childname + instance; } // locate clone's home var inserthere = document.getelementbyid(clonehome); // place clone in home inserthere.parentnode.insertbefore(tempclone,inserthere); } } window.onload = function() { morefields('snackbox', 'snackplate'); } js2
var counter = 0; function addmorefields(srchome, clonehome) { // check if there isn't more 3 fields if(counter != 3) { counter++; // create child var template = document.getelementbyid(srchome).clonenode(true); // remove templet clone's id avoid future confusion template.id = ""; template.style.display = 'block'; /* cloned templet's * children. here make * ones have name * unique. */ var copy = template.childnodes; for(var = 0; < copy.length; i++) { var clonename = copy[i].name; if(clonename) copy[i].name = clonename + counter; } // locate clone's home var endlocation = document.getelementbyid(copyhome); // place clone in home endlocation.parentnode.insertbefore(template,endlocation); } } window.onload = function() { addmrefields('soupbox', 'soupbowl'); } html code
<td><div id="snackbox" style="display:none"> <select id="dfood" name="dfood"> <option>--select--</option> <?php $result = mysql_query("select * survival_mode.dryfood_t", $link); while($row = mysql_fetch_array($result)) { echo "\n\t\t\t\t\t\t<option value='{$row['dfood_id']}'>{$row['dfood_name']}</option>"; } echo "\n"; ?> </select> <input name="df_qty" type="text" placeholder="qty" size="1" maxlength="1"/> <?php if($climate == "warm") { echo "\n\t\t\t\t<input type='button' value='-' onclick='if(instance > 1){instance--; this.parentnode.parentnode.removechild(this.parentnode);}' />"; echo "\n\t\t\t\t<input type='button' value='+' onclick='morefields(\"snackbox\", \"snackplate\");' />"; } echo "\n"; ?> </div> <span id="snackplate"></span> </td> <td><div id="soupbox"> <select id="soup" name="soup"> <option>--select--</option> <?php $result = mysql_query("select * survival_mode.soup_t", $link); while($row = mysql_fetch_array($result)) { echo "\n\t\t\t\t\t\t<option value='{$row['soup_id']}'>{$row['soup_name']}</option>"; } echo "\n"; ?> </select> <input name="s_qty" type="text" placeholder="qty" size="1" maxlength="1" /> <?php if($climate == "cold") { echo "\n\t\t\t\t<input type='button' value='-' onclick='if(counter > 1){counter--; this.parentnode.parentnode.removechild(this.parentnode);}' />"; echo "\n\t\t\t\t<input type='button' value='+' onclick='addmorefields(\"soupbox\", \"soupbowl\");' />"; } echo "\n"; ?> </div> <span id="soupbowl"></span> </td>
Comments
Post a Comment