Click to See Complete Forum and Search --> : Alert box
GurusGuru
01-08-2003, 11:39 PM
I would like to give an 'Alert' on a html link. Say the link is 'User Details'. When a visitor clicks on 'User Details' and alert should pop up with a message "Do you want to change profile?". The alert should have 2 buttons 'Yes' & 'No'. When the visitor clicks on 'Yes' button he should be taken to url - http://www.xyz123.com and it should open in a new window. If the visitor clicks on 'No' he should be taken to a page 'abcd.html' which should open in the same frame (target=_self) or a defined frame (target=mainframe).
Try this code:
<html>
<head>
<title></title>
<script language="JavaScript">
<!--
function confi(PositiveHref,NegativeHrefs){
var con = window.confirm('Do you want to change profile');
if(con == true){
window.open(PositiveHref,'Edit','width=500,height=400')}
else{
window.location.href= NegativeHrefs;}
}
//-->
</script>
</head>
<body>
<a href="mainframe.html" onClick="confi(this.href,'abcd.html');return false;">test</a>
</body>
</html>
GurusGuru
01-09-2003, 03:05 AM
Thanks. Works very well.
GurusGuru
01-10-2003, 12:39 AM
Can the above script be redefined for a form.
Below is a form. After clicking on the 'Submit Profile' button the data from the form gets inserted in a file on the server and 'A Page' (defined in the script) opens. Can this page open in a new window and another page thank.htm opens in the same frame in which the form opened.
<form name="form1" action="http://www.kidsmissing.com/cgi-bin/missing.pl" method="post" enctype="multipart/form-data" onsubmit="return checkFields(this);">
<div align="center">
<center>
<table width="90%" bordercolor="#FFFFFF" border="1" cellspacing="0" cellpadding="2">
<tr>
<td>First Name</td>
<td><input type="text" name="FirstName" size="30" maxlength="25"></td>
</tr>
<tr>
<td>Last Name</td>
<td><input type="text" name="LastName" size="30" maxlength="25"></td>
</tr>
<tr>
<td>Email</td>
<td><input type="text" name="Email" size="30" maxlength="35"></td>
</tr>
<tr>
<td>City</td>
<td><input type="text" name="City" size="20" maxlength="20"></td>
</tr>
</table>
</center>
</div>
<br>
<input type="submit" name="perlfunc" value="Submit Profile"> <input type="reset" value="Clear">
</form>
Hi, one question, do you want it with the window.prompt function?
Maybe that's what you need:
GurusGuru
01-10-2003, 04:16 AM
I am attaching the javascript that I am using for validation. Please could you check if I have added the lines (last 3) correctly.
No window prompt function for the form submission.
Looks good, should works correctly! Don't forget the form-tag.