hi all,
i had created a page in which users can be seen. and a edit button to edit. wen i click on the edit button a popup window will open and after edit is done and press submit button i wil get a msg that data editted. But the window is not closing. i need the window to close.
Thank u.

Member Avatar for rajarajan2017

Sample:

<a href="javascript:top.close();"><img src="images/Exit.gif" style="position: absolute; right:5px; top:5px; left:310px" border="0"></img></a>

Sample:

<a href="javascript:top.close();"><img src="images/Exit.gif" style="position: absolute; right:5px; top:5px; left:310px" border="0"></img></a>

my code is this

<td  align="left" style="width: 177px"><a href="Admin.php" onclick="window.open('http://localhost/Project/usercreation1.php','popup','width=400,height=250,scrollbars=no,resizable=no,toolbar=no,directories=no,location=center,menubar=no,status=no,left=370,center=0,top=300')">Add Users</a></td>

wen i click on addusers a window will open. Now wer should i put ur code.

hi niths where you have submit the data's at that button add window.close button()

like

<input type="submit" name="Submit" id="button" value="Submit" onclick="window.close()"/>

Member Avatar for rajarajan2017

From the popup window have a button and use onclick="closefn"

within the closefn
use top.close();
or self.close();

Member Avatar for rajarajan2017
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
	<title>Untitled</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="language" content="en" />
	<meta name="description" content="" />
	<meta name="keywords" content="" />
	<script language="javascript">
		function closefn(){
			self.close();
		}
	</script>
</head>
<body>
<input type="submit" name="Submit" id="button" value="Submit" onclick="closefn();"/> 
</body>
</html>

From the popup window have a button and use onclick="closefn"

within the closefn
use top.close();
or self.close();

can u say it again.i didnt understand, as i am new to php. i am posting my code here.

<html>
<body>
<script language="javascript" type="text/javascript">
		function check()
		{
			if(document.getElementById('txtusrid').value == "")
			{
				alert('Please enter Username');
				return false;
				
			}
			if(document.getElementById('txtpwd').value == "")
			{
				alert('Please enter password');
				return false;
			}
            if(document.getElementById('txtrep').value == "")
            {
                alert('Please enter reportingto');
                return false;
            }
		}
	</script>

<form action="insertuser.php" method="post">
<table align="center">
    
    <tr>
        <td style="color: navy;">Username</td>
        <td><input id="txtusrid" type="text" name="username"></td>
    </tr>
    <tr>
        <td style="color: navy;">Password</td>
        <td><input id="txtpwd" type="password" name="password"></td>
    </tr>
    <tr>
        <td style="color: navy;">Role</td>
        <td><select name="role">
        
        <option value="User" selected="selected">User</option>
        </select>
       </td>
    </tr>
    
    <!--<tr>
        <td style="color: navy;">Status:</td>
        <td><select name="status">
        
        <option value="Active" selected="selected">Active</option>
        </select>
       </td>
    </tr>-->
     
    <tr>
        <td></td>
        <td><input type="submit" name="btn" value="Submit" onclick="return check();"></td>
</table>
</form>
</body>
</html>
Member Avatar for rajarajan2017

You asked how to close a window? what the above code relevant to?

You asked how to close a window? what the above code relevant to?

code present in pop up window

Member Avatar for rajarajan2017

Just add this line

<td><input type="submit" name="closebtn" value="Close" onclick="window.close();"></td>

after

<td><input type="submit" name="btn" value="Submit" onclick="return check();"></td>

I used close button, you can create a grahic like x as a small image and use the onclick="window.close();"

hey bee

do the following

in your insertuser.php

after php code add the following

<script language="javascript" type="text/javascript">
window.close();
</script>

Just add this line

<td><input type="submit" name="closebtn" value="Close" onclick="window.close();"></td>

after

<td><input type="submit" name="btn" value="Submit" onclick="return check();"></td>

I used close button, you can create a grahic like x as a small image and use the onclick="window.close();"

i think u didnt understand my query. i am sorry for my poor english

<td  align="left" style="width: 177px"><a href="Admin.php" onclick="window.open('http://localhost/Project/usercreation1.php','popup','width=400,height=250,scrollbars=no,resizable=no,toolbar=no,directories=no,location=center,menubar=no,status=no,left=370,center=0,top=300')">Add Users</a></td>

this is my pop up window. so wen i click on addusers i wil get a window with some fileds and after filling those fields i wil click on submit button and now that details will get added in to database. Now the popup window which i had done all these need to get closed automatically. so i think u understood my query.

i understood what you want, you do the above steps man

where you add the data's in to DB afterward s you have to add

<script>
window.close();
</script>

i understood what you want, you do the above steps man

where you add the data's in to DB afterward s you have to add

<script>
window.close();
</script>

ya thank u i got it.

Member Avatar for rajarajan2017

USH..........COOL!

Member Avatar for rajarajan2017

Within the check function write the code window.close() before the closing brace.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.