c# - Textbox onchange event -
so have text box, add onchange event of markasexception.
my javascript -
function markasexception(recordid) { //alert("exception"); //mark exception column document.getelementbyid("ctl00_cpmain_lblscrollexception_" + recordid).innertext = "exception"; document.getelementbyid("ctl00_cpmain_lblscrollexception_" + recordid).style.color = "#ff0000"; document.getelementbyid("ctl00_cpmain_tdscrollexception_" + recordid).style.backgroundcolor = "#99ccff"; //enable comments ddl , remove blank (first item) document.getelementbyid("ctl00_cpmain_ddlcommentid_" + recordid).disabled = false; document.getelementbyid("ctl00_cpmain_ddlcommentid_" + recordid).focus(); document.getelementbyid("ctl00_cpmain_ddlcommentid_" + recordid).options[0] = null; }
what want is, when user changes value in textbox, mark column "exception", , focus drop down list have chose reason exception.
this happens.. if on text box , change it, tab, tabs drop down list.
however, if change value , click in text box on form, don't focus drop down list.
how accomplish that?
i suggest using jquery's change() function.
the advantage more stable across different browsers.
something like:
$('#<%= textbox1.clientid %>').change(function(){ // extract recordid textbox - perhaps attribute? markasexception(recordid); });
my comment getting longer i'm expanding:
take @ jquery documentation setting page finishes loading. if tb id of textbox selector be
$('#<%= tb.clientid %>')
i suggest replace code , use
tb.attributes.add("recordid", recordid.tostring());
this add id need onto textbox tag. once you're in function outlined above can use following selector recordid in javascript
var recordid = $('#<%= textbox1.clientid %>').attr('recordid');
all together
$(document.ready(function(){ $('#<%= tb.clientid %>').change(function(){ var recordid = $('#<%= tb.clientid %>').attr('recordid'); if(recordid){ markasexception(recordid); } }); });
Comments
Post a Comment