Showing posts with label javascript. Show all posts
Showing posts with label javascript. Show all posts

Monday, May 23, 2011

auto refresh parent page after close popup page.

1. place this code in child / pop-up page



function refreshParent(){ window.opener.location.href = window.opener.location.href;
if (window.opener.progressWindow) { window.opener.progressWindow.close() }
window.close();
}


2. Place a button to call the above JavaScript function at the bottom of the pop-up window, so when user clicks on the button, it’ll refresh the parent window and closes itself.





<input type=button value=”Close” onClick=”refreshParent();”/>

check empty fields and warn user to fill javascript

function check_field()
{

var myField=["lec_name","Name","lec_ic","IC"];
alert(myField.length);

for(x=0; x
{ var z = myField[x];
var y= myField[x+1];

if ( document.form1.elements[z].value =='' || document.form1.elements[z].value==null)
{
alert ("fill "+ y +" !");document.form1.elements[z].focus();return false;
}

x++;
}


}