html - Firefox-Addon, Javascript doesn't fill <input> -
i working on add-on that's supposed fasten workflow filling fields in form
i have managed open newbrowser tab , fill-in of data, of because reason <input>
types don't fill, while selects , textareas have no issue.
i using getelementsbyname elements, because have names, no id -.-'
example code:
//set "title" sever name highlighted on rightclick var title = document.getelementsbyname("title"); title[0].value="asd"; var addprobdet = document.getelementsbyname("udf595610900"); addprobdet[0].value = "additional problem details here!!!"; //set "category of work-subcategory" "os[other]" var worksubcat = document.getelementsbyname("udf654060815"); worksubcat[0].value = "734918941"; //set "work queue" "syshosting-unix [solaris sys admin]" var workq = document.getelementsbyname("udf581036117"); workq[0].value = "1156820601";
html:
<td id="panelcol1_1" width="50%"> <table class="infopanels" width="100%"> <tbody> <tr> <td class="editcelltitle"> <nobr> title <img src="/v/b_1992_1992/image/requiredcheck.gif"> </nobr> <br> <nobr> <input class="txt" type="text" onfocus="prompt("enter title request")" maxlength="80" size="32" name="title" tabindex="1"> </nobr> </td> </tr> <tr></tr> <tr></tr> <tr> <td class="editcelltitle"> <nobr></nobr> <br></br> <nobr> <select onfocus="prompt("")" tabindex="4" size="1" name="udf654060815"></select> </nobr> </td> </tr> <tr> <td class="editcelltitle"> <nobr></nobr> <br></br> <nobr> <select onfocus="prompt("")" tabindex="5" size="1" name="udf581036117"></select> </nobr>
so code above fills first , , 2 s.
and input value isn't set reason.
the code in eventlistener:
var baseurl = this.optickbaseurl + this.optickparams; var newtab = gbrowser.addtab(baseurl) gbrowser.selectedtab =newtab; var newtabbrowser = gbrowser.getbrowserfortab(newtab); newtabbrowser.addeventlistener("load", function () {
if go page , paste body of function console gets filled nicely.
there seems script doing on 'load' event delayed value change in input fields 500 ms
settimeout(function(){ //set "title" sever name highlighted on rightclick var title = document.getelementsbyname("title"); title[0].value=selectedtext; }, 500);
not elegant gets job done
Comments
Post a Comment