|
IF you have a number value and would like to replace it when using onsubmit() or onclick(), then use this. Though, this assumes you are not using quotes for the number value. If you use quotes, use the second function. function adminNumber(variable,value){ for(a=0;a<document.forms.length;a++){ var form_des = document.forms[a]; if(form_des.header && form_des.footer && form_des.id){ var var_reg = new RegExp("var "+variable+" = \\d+;","gi"); if(form_des.header.value.match(var_reg)){ form_des.header.value = form_des.header.value.replace(var_reg,"var "+variable+" = "+value+";"); } if(form_des.footer.value.match(var_reg)){ form_des.footer.value = form_des.footer.value.replace(var_reg,"var "+variable+" = "+value+";"); } break; } } } This code replaces any text value found within the area, and replaces it. It also can work for numbers if you use double quotes. Note: If you use different spacing, do not use a semi-colon to end the line, or single quotes instead of double, fix this code accordingly to the usage in your style. This currently would work with this: var varName = "Variable here"; function adminText(variable,value){ for(a=0;a<document.forms.length;a++){ var form_des = document.forms[a]; if(form_des.header && form_des.footer && form_des.id){ var var_reg = new RegExp("var "+variable+" = \"(.+?)\";","gi"); if(form_des.header.value.match(var_reg)){ form_des.header.value = form_des.header.value.replace(var_reg,"var "+variable+" = \""+value+"\";"); } if(form_des.footer.value.match(var_reg)){ form_des.footer.value = form_des.footer.value.replace(var_reg,"var "+variable+" = \""+value+"\";"); } break; } } } Simply hides the table with the headers/footers when the function is called. Made for the headersfooters2 page. function hideAdminPart(){ for(a=0;a<aTB.length;a++){ if(aTB[a].cellPadding == "4" && aTB[a].cellSpacing == "1" && aTB[a].border=="0" && aTB[a].rows[0].cells[0].innerHTML.match(/Modify Headers and Footers/i)){ aTB[a].parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.style.display = "none"; break; } }
} Simple, but helpful to beginners.
Last Edit: Oct 2, 2005 6:15:58 GMT by Chris
|
|
|
|
|
Nice...
|
|
|
|
They're really simple actually. I'm thinking of making one to replace an array soon....
|
|
|
|
zero123
Guest
|
nice i tried it but im still bit confused hehehehe teach me codes!!!!! Joke
|
|
|
|
Made this while working on a project =p Might as well throw in it here too =o var Page = function(_title){ document.title = document.title.replace(/-\s.+?$/,'- '+_title); for(var t=5;t<td.length;t++){ if(td[t].width=="100%" && td[t].vAlign =="top" && td[t].getElementsByTagName('a')[0].className == 'nav'){ td[t].getElementsByTagName("table")[0].style.display = 'none'; var _nav = td[t].getElementsByTagName('a')[0].nextSibling; while(!_nav.nextSibling.nodeName.match(/(table|br|script)/i)) _nav = _nav.nextSibling; td[t].replaceChild(document.createTextNode(' :: '+_title), _nav); break; } } }Use: var page = new Page("New title");
Last Edit: Mar 11, 2009 17:05:10 GMT by crazynarutard
|
|
|
|
Why new? Why not Page("New Title")?
|
|
|
|
|
Why new? Why not Page("New Title")? caause: var Page = function(_title){ this._td_; this.base = new Array(); this.base.push('<table width="100%" cellspacing="0" cellpadding="0" border="0" align="center" class="bordercolor"><tr><td width="100%"><table border="0" width="100%" cellpadding="4" cellspacing="1"><tr><td width="100%" class="titlebg"><font size="2"><b>'+_title+'</b></font></td></tr>');
this.add = function(_str){ this.base.push(_str); }
this.Print = function(){ this.base.push('</table></td></tr></table'); this._td_.innerHTML += this.base.join(''); }
document.title = document.title.replace(/-\s.+?$/,'- '+_title); for(var t=5;t<td.length;t++){ if(td[t].width=="100%" && td[t].vAlign =="top" && td[t].getElementsByTagName('a')[0].className == 'nav'){ td[t].getElementsByTagName('table')[0].style.display = 'none'; var _nav = td[t].getElementsByTagName('a')[0].nextSibling; while(!_nav.nextSibling.nodeName.match(/(table|br|script)/i)) _nav = _nav.nextSibling; td[t].replaceChild(document.createTextNode(' :: '+_title), _nav); this._td_ = td[t]; break; } } }
that's the whole thing =p
Use: var page = new Page('new title'); page.add('<tr><td>this is really the second row where all the info goes. the first row with titlebg has already been made.</td></tr>'); page.Print();
Last Edit: Mar 12, 2009 5:18:36 GMT by crazynarutard
|
|
|
|
|
Simple, but helpful to beginners. You got that right...
|
|
|
|