April 14th, 2008 |
by Knix |
published in
javascript
function addContent(divName, content) {
document.getElementById(divName).innerHTML = content;
}
function setCookie(c_name,value,expiredays) {
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ “=” +escape(value)+((expiredays==null) ? “” : “;expires=”+exdate.toGMTString());
}
function getCookie(c_name) {
if (document.cookie.length>0) {
c_start=document.cookie.indexOf(c_name + “=”);
[...]
March 5th, 2008 |
by Knix |
published in
javascript
There is a rare need for this type of functionality but I have found myself in a couple of situations where I needed it. Here is a quick demo of a button click that is simulated from another event handler. In this case, the button click is invoked by checking a checkbox.
Demo
Check the [...]
February 28th, 2008 |
by Knix |
published in
javascript
function selectToggle(toggle, form) {
var myForm = document.forms[form];
for( var i=0; i < myForm.length; i++ ) {
if(toggle) {
myForm.elements[i].checked = “checked”;
[...]
February 27th, 2008 |
by Knix |
published in
javascript
function verifyForm(form) {
var userName = form.name.value;
var userEmail = form.email.value;
var success = 1;
if (!userName) {
document.getElementById(“usernameMsg”).style.display = “”;
form.name.style.backgroundColor = “yellow”;
[...]
February 21st, 2008 |
by Knix |
published in
javascript
Not all forms are meant to be static. Sometimes, you want to allow the users to add certain parts of the form as they need them. Here is a nice example of dynamically adding inputs to your form as users need them. In addition, an input limit has been implemented in the [...]
February 9th, 2008 |
by Knix |
published in
javascript
I have found myself in a couple of situations where I needed a simple dynamic javascript menu where the user would make a selection from one select list and depending on what the user selected from the first select list a second list would offer further options. Here is a perfect example:
Demo
Country:
Select country… [...]