elikkäs. päivitellyt tässä mozilla extensionia ja nyt pitäs saada lisättyä erääseen scriptiiin vähän lisä materiaalia mutta hirveästi ei ole kokemusta eikä noi oppaat oikeen auta
eli tämmönen pätkä pitäs saada lisättyä
<center><form name="form1" method="post" action=""> <table width="345" border="0" cellspacing=0 cellpadding=0> <tr> <td width="134"><strong>Land: <input name="textfield" type="text" size="8"> </strong></td> <td width="106"><strong>Oceanic? <input type="checkbox" name="oceanic" value="oceanic"> </strong></td> <td width="105"><input type="button" name="Submit" value="Calculate" onClick="calculateResearch()"></td> </tr> </table> </form></center>
ja alkuperäinen research.js näyttääpi tältä
var land; var rpop; var rpow; var rmil; var rmon; var rfdc; function calculateResearch(){ land = parseInt(document.form1.textfield.value); if (document.form1.textfield.value == "") {land = 0} rpop = parseInt(land * land * 0.0094); rpow = parseInt(land * land * 0.0063); rmil = parseInt(land * land * 0.0061); rmon = parseInt(land * land * 0.011); rfdc = parseInt(land * land * 0.017); rrwc = parseInt(land * land * 0.0121); if (document.form1.oceanic.checked == true) { rpop = parseInt(rpop * 1.2); rpow = parseInt(rpow * 1.2); rmil = parseInt(rmil * 1.2); rmon = parseInt(rmon * 1.2); rfdc = parseInt(rfdc * 1.2); rrwc = parseInt(rrwc * 1.2); } alert("Population bonus: " + rpop + " \n" + "Power bonus: " + rpow + " \n" + "Military bonus: " + rmil + " \n" + "Money bonus: " + rmon + " \n" + "Frequency Decryption: " + rfdc + " \n" + "Reactor Warp Core: " + rrwc + " ") } function MaxScis(){ var tds = document.getElementsByTagName("form")[0] var maintable = tds var cellHTML = tds.parentNode.innerHTML; var lead = cellHTML.indexOf("scientists.<br>You have <b>"); var posStart = lead + 27; var without_resource = cellHTML.substring(posStart, cellHTML.length); var posEnd = without_resource.indexOf("</b>"); var maxScis = without_resource.substring(0, posEnd).replace(/,/g , ""); var srows = maintable.getElementsByTagName("tr"); for(var i = 0; i< srows.length; i++) { var cellrow = srows[i]; var cells = cellrow.cells; var box = cellrow.getElementsByTagName("input")[0]; if(cellrow.innerHTML.match("Number of scientists")){ } else if(box.name){ cells[4].innerHTML = cells[4].innerHTML + ' - <a href="javascript:void(null)" onclick="var form = document.getElementsByName(' + box.name + ');form[0].value = ' + maxScis + '">Max</a>'; } } } MaxScis(); calculateResearch()
kiitosta etukäteen.
Aihe on jo aika vanha, joten et voi enää vastata siihen.