Category Archives: JavaScript / CSS

SCROLL TO BOTTOM ON BUTTON CLICK

HTML —- LT div id=”main” GT LT div class=”container-fluid” id=”subParentDiv” GT LT /div GT LT /div GT JAVA SCRIPT ———– function checkScroll(){ scroll_to($(“#main”), $(“#subParentDiv”)); } function scroll_to(base, target){ base.animate( { scrollTop:target.height() },1000 ); } EXPLANATION ———– Call the checkScroll() function … Continue reading

Posted in JavaScript / CSS, JQuery | Leave a comment

Copy Particular Row and Append it in a Table

function copyAndAppend(id){ $(“#”+id+” tr:last”).after(“ ” + $(“#serviceRow”).html() + “ “); } Explanation: 1) $(“#serviceRow”).html() : I will copy all the inner content of an element having id = “serviceRow” 2) $(“#”+id+” tr:last”) : I have used ‘id’ variable, its value … Continue reading

Posted in JavaScript / CSS, JQuery | Leave a comment

JAVA SCRIPT CODE TO KEEP THE SCROLLBAR AT BOTTOM

HTML====<div id=”mainParentDiv” style=”padding-left:2.4em;display:block;overflow-y: auto;height:500;width: 800px;”>    <div id=’serverLogsParent’ width=”97%” border=”0″>        <div id=’serverLogs’ width=”97%” border=”0″></div>        <div id=”progressDiv” align=”bottom” >        <img align=”bottom” alt=”Fetching Logs” src=”${pageContext.request.contextPath}/images/progress.gif”/>        </div>    </div></div> JAVA SCRIPT==========<sctipt>scroll_to($(‘#mainParentDiv’), $(“#progressDiv”)); function scroll_to(base, target){        base.animate({        scrollTop: $(“#serverLogs”).height()         … Continue reading

Posted in JavaScript / CSS | Leave a comment

CHANGE IMAGE SRC VALUE ON ITS CLICK EVENT

JAVA SCRIPT CODE ================  function changeImageSrc(thisElement){ var newSrc ; if($(thisElement).attr(“src”).indexOf(“showme.png”)!=-1){ newSrc = $(thisElement).attr(“src”).replace(“showme.png”, “hideme.png”); }else{ newSrc = $(thisElement).attr(“src”).replace(“hideme.png”, “showme.png”); } $(thisElement).attr(“src”, newSrc); } HTML CODE =========== <img src=”<%=basePath%>/images/showme.png” alt=”Edit” border=”0″ id=”showLogMonitors” value=”Show Monitors” onclick=”showHideLogMonitorList(this);” />

Posted in JavaScript / CSS, JQuery | Leave a comment

Water Mark java script function for username/password

function watermark(inputId,text){ var inputBox = document.getElementById(inputId); document.getElementById(inputId).style.color=”black”; if (inputBox.value.length > 0){ if (inputBox.value == ‘UserName’){ inputBox.value = ”; } if (inputBox.value == ‘Password’){ inputBox.value = ”; inputBox.type = “password”; } if (inputBox.value == ‘Security Code’){ inputBox.value = ”; } } … Continue reading

Posted in JavaScript / CSS, JQuery | Leave a comment

Java Script Regex for IPV4 validation with netmask

var ipv4RangeRegex = /^(1\d{0,2}|2(?:[0-4]\d{0,1}|[6789]|5[0-5]?)?|[3-9]\d?|0)\.(1\d{0,2}|2(?:[0-4]\d{0,1}|[6789]|5[0-5]?)?|[3-9]\d?|0)\.(1\d{0,2}|2(?:[0-4]\d{0,1}|[6789]|5[0-5]?)?|[3-9]\d?|0)\.(1\d{0,2}|2(?:[0-4]\d{0,1}|[6789]|5[0-5]?)?|[3-9]\d?|0)(\/(?:[012]\d?|3[012]?|[0-9]?)){0,1}$/;    

Posted in JavaScript / CSS | Leave a comment

Java Script to Add-Remove Select Options

function demoFun(){ var countryIdJS = document.getElementById(“countryId”).value; var regionSelect = document.getElementById(‘regionId’); regionSelect.options.length = 0; // delete all existing options regionSelect.options[0] = new Option (“–Select–“,”0”); // above line will add new option with value “0” and displayText “–Select–“ regionSelect.options[0].selected=”true”; // above line … Continue reading

Posted in JavaScript / CSS, Uncategorized | Leave a comment