Jump to content

hAnDoFhOnOr

Members
  • Posts

    7
  • Joined

  • Last visited

Everything posted by hAnDoFhOnOr

  1. I need to get the name of document.getElementBy(app_table).cells(1).so the appliance in b.innerhtml , this changes everytime but if i reference the row i can get it i just can't get the right syntax. i know it's a long code but anyhelp would be appreciated. function addRow(classification, appliance, quantity, origquantity, costpermonth, wattage, hoursused, daysused, weeksused, row){ var app_table = 'table_' + classification; var x=document.getElementById(app_table).insertRow(row); var a=x.insertCell(0); var b=x.insertCell(1); var c=x.insertCell(2); a.innerHTML = '<input type="text" maxlength="2" class="formtext5" name="' + classification + '_quantity' + (document.getElementById(app_table).rows.length - 1) + '" value="' + quantity + '" onchange="JavaScript:if(checkNum(this.value, "Appliance Quantity")){this.focus();this.value=this.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.value;}else{checkRemaining(Number(this.value-this.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.value)*Number(this.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.value), Number(document.energy.remaining.value));editQuantity(this.parentNode.parentNode.parentNode.parentNode.id, this.parentNode.parentNode.rowIndex);this.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.value=this.value;updateCES();if(this.parentNode.parentNode.parentNode.parentNode.rows.length>2){verifyPos(this.parentNode.parentNode.parentNode.parentNode.id, this.parentNode.parentNode.rowIndex);}}"><input type="hidden" name="' + classification + '_wattage' + (document.getElementById(app_table).rows.length - 1) + '" value="' + wattage + '"><input type="hidden" name="' + classification + '_hoursused' + (document.getElementById(app_table).rows.length - 1) + '" value="' + hoursused + '"><input type="hidden" name="' + classification + '_daysused' + (document.getElementById(app_table).rows.length - 1) + '" value="' + daysused + '"><input type="hidden" name="' + classification + '_weeksused' + (document.getElementById(app_table).rows.length - 1) + '" value="' + weeksused + '"><input type="hidden" name="' + classification + '_origquantity' + (document.getElementById(app_table).rows.length - 1) + '" value="' + origquantity + '"><input type="hidden" name="' + classification + '_costpermonth' + (document.getElementById(app_table).rows.length - 1) + '" value="' + costpermonth + '">'; b.innerHTML = appliance; c.innerHTML = '<nobr><input type=<input type="text" class="formtext6" name="' + classification + '_amount' + (document.getElementById(app_table).rows.length - 1) + '" value="' + round(Number(quantity)*Number(costpermonth), 2) + '" onfocus="this.blur();"> <input type="image" src="images/b-x.gif" name="' + classification + '_delete' + (document.getElementById(app_table).rows.length - 1) + '" id="' + classification + '_delete' + (document.getElementById(app_table).rows.length - 1) + '" width="8" height="9" border="0" alt="Remove appliance" onclick="removeRow(this.parentNode.parentNode.parentNode.parentNode.parentNode.id, this.parentNode.parentNode.parentNode.rowIndex);"> <input type="image" src="images/b-check.gif" name="' + classification + '_edit' + (document.getElementById(app_table).rows.length - 1) + '" id="' + classification + '_edit' + (document.getElementById(app_table).rows.length - 1) + '" width="12" height="10" border="0" alt="Edit appliance" onclick="this.parentNode.parentNode.parentNode.className=tdcon4;editAppliance(this.parentNode.parentNode.parentNode.parentNode.parentNode.id, this.parentNode.parentNode.parentNode.rowIndex);"></nobr>'; var y=document.getElementById(app_table).rows; y[row].className = "tdcon3"; y[row].firstChild.nextSibling.nextSibling.className = "tdcon2";}function removeRow(app_table, i){ document.getElementById(app_table).deleteRow(i); if (applianceCount()<=0){ document.energy.remaining.value=""; document.energy.total.value=""; resetPie(); } else { updateCES(); }}
  2. I need to get the name of document.getElementBy(app_table).cells(1).so the appliance in b.innerhtml , this changes everytime but if i reference the row i can get it i just can't get the right syntax. i know it's a long code but anyhelp would be appreciated.
  3. I need to get the name of document.getElementBy(app_table).cells(1).so the appliance in b.innerhtml , this changes everytime but if i reference the row i can get it i just can't get the right syntax. i know it's a long code but anyhelp would be appreciated.
  4. i have seen that page already, as i've said i know i can use the splice() function but i need something that can determine the index of a specific element in an array. I have been trying to usevar arr_index = array.indexOf(array_element); so that i can use array.splice(arr_index, 0); to remove the element. But it doesn't seem to work, any thoughts? I'll appreciate it very much.
  5. i know that you can use the splice() function to remove elements in an array by specifying the index of the element you want to remove. my question is what if you do not know the index but know the specific element you want to remove.e.g. array animal = new Array ("cat, dog, mouse, rat, cow");if you want to remove the element mouse, you can do animal.splice(2,0) right?but what if i don't know the index, is there a javascript function that lets you search for a specific element index. Does array.indexOf(array_element) work in javascript? thanks.
  6. thanks for that aspnetguy, i have tried that approach, i'm wondering if their is a way were the user wouldn't need to click the row headers. i mean, the rows will automatically update themselves once a new value is added to the list. again thanks in advance.
  7. Hi, first of my english is not very good so i will try to make it as clear as possible. ThanksI was wondering if you have any suggestions with my problem. I want my table to be sorted according to a specific column. But my problem is the values are from a javascript function (w/c also makes me wonder if i should have posted this in the javascript forum below instead). anyway here is what the table looks like <table border="0" cellpadding="0" cellspacing="3"><tr> <td width="15" bgcolor="#0000ff"> </td> <td width="100"><input type="text" name="label_acu" value="Aircon" class="formtext11" onfocus="this.blur();"></td> <td width="15" class="formtext9">|</td> <td><input type="text" name="amt_acu" value="PhP 0" class="formtext10" onfocus="this.blur();"></td> <td width="15" class="formtext9">|</td> <td><input type="text" name="percent_acu" value="0%" class="formtext9" onfocus="this.blur();"></td></tr><tr> <td bgcolor="#9ACD32"> </td> <td><input type="text" name="label_ref" value="Refrigerator" class="formtext11" onfocus="this.blur();"></td> <td class="formtext9">|</td> <td><input type="text" name="amt_ref" value="PhP 0" class="formtext10" onfocus="this.blur();"></td> <td class="formtext9">|</td> <td><input type="text" name="percent_ref" value="0%" class="formtext9" onfocus="this.blur();"></td></tr><tr> <td bgcolor="#ff0000"> </td> <td><input type="text" name="label_cok" value="Cooking" class="formtext11" onfocus="this.blur();"></td> <td class="formtext9">|</td> <td><input type="text" name="amt_cok" value="PhP 0" class="formtext10" onfocus="this.blur();"></td> <td class="formtext9">|</td> <td><input type="text" name="percent_cok" value="0%" class="formtext9" onfocus="this.blur();"></td></tr><tr> <td bgcolor="#ffff00" > </td> <td><input type="text" name="label_fan" value="Fan" class="formtext11" onfocus="this.blur();"></td> <td class="formtext9">|</td> <td><input type="text" name="amt_fan" value="PhP 0" class="formtext10" onfocus="this.blur();"></td> <td class="formtext9">|</td> <td><input type="text" name="percent_fan" value="0%" class="formtext9" onfocus="this.blur();"></td></tr><tr> <td bgcolor="#d2691e"> </td> <td><input type="text" name="label_ent" value="Entertainment" class="formtext11" onfocus="this.blur();"></td> <td class="formtext9">|</td> <td><input type="text" name="amt_ent" value="PhP 0" class="formtext10" onfocus="this.blur();"></td> <td class="formtext9">|</td> <td><input type="text" name="percent_ent" value="0%" class="formtext9" onfocus="this.blur();"></td></tr><tr> <td bgcolor="#ee82ee"> </td> <td><input type="text" name="label_gap" value="Gen. Appliances" class="formtext11" onfocus="this.blur();"></td> <td class="formtext9">|</td> <td><input type="text" name="amt_gap" value="PhP 0" class="formtext10" onfocus="this.blur();"></td> <td class="formtext9">|</td> <td><input type="text" name="percent_gap" value="0%" class="formtext9" onfocus="this.blur();"></td></tr></table> currently they are in a fixed position, the values on the amt and percent column changes each time a new appliance is added to the list. i was wondering if anyone would have any suggestion?values are assigned like document.energy_form.amt_aircon.value = aircon_value to each appliance everytime.I would like for them to change in order e.g. the appliance with the biggest amount will be in the first row, followed by the second biggest and so on. I know i won't be able to do it with html alone, and i was trying to figure out if i could possibly use layers. Any suggestions?thanks again in advance.
×
×
  • Create New...