Archive for August, 2009


>

function addoption(text,id) {
var feed = document.form.selectboxname;
var flag=true;
for (i=0;i<feed.length;i++) &&=”” (!flag)=”” (feed.options[i].value=”=id)” (feed.selectedindex=”” );=”” alert(=”” already=”” feed.options[feed.length]=”new” feed=”document.form.selectboxname;” flag){=”” flag=”false;” function=”” id);=”” id=”” if(text=”” if=”” inserted=”” option(text,=”” remove_category()=”” var=”” {=”” }=”” }else{=””>= 0) feed.remove(feed.selectedIndex);
}</feed.length;i++)>

>Charecter Count

Posted: August 5, 2009 in JS

>var isInternetExplorer = (navigator.appName.indexOf(“Microsoft”) != -1);
function countLineBreaks(obj){
var iLength = obj.value.length;
var strLineBreaks = obj.value.match(new RegExp(“(\\n)”, “g”));
var countLineBreaks = strLineBreaks ? strLineBreaks.length : 0;
return countLineBreaks;
}

function textCounter(field, counter_field, maxlimit) {
var lineBreaks = countLineBreaks(field);
var adjust = isInternetExplorer ? 1 : 0;
if (field.value.length – lineBreaks * adjust > maxlimit){
field.value = field.value.substring(0, maxlimit + lineBreaks * adjust);
field.focus();
} else {
counter_field.value = maxlimit – field.value.length + lineBreaks * adjust;
}
}

textarea name=”summary_desccription” id=”summary_description” rows=”5″ onKeyDown=”textCounter(this.form.summary_desccription,this.form.remLen,10);” onKeyUp=”textCounter(this.form.summary_desccription,this.form.remLen,10);”