Click to See Complete Forum and Search --> : Alert Variable


neil9999
07-13-2003, 02:19 AM
Hi,

I've got two questions:

1) I'm trying to make an alert with the contents of whatever's in the text box named alert appear when you click a button. Could someone tell me what's wrong with the button below?

<input type="button" value="Preview" name="Preview" onclick="alert(\"" + form.alert.value + "\");>

2) Is it possible to make a popup window without the titlebar without making it full screen?

Thanks,

Neil

Khalid Ali
07-13-2003, 05:58 AM
change this part of the code
+ form.alert.value +
to this

+ this.form.alertField.value

and make sure your html elements do not have names matching javascript or html keywords that can cause un expected results.

Second part of your question...full screen mode without title bar only works in IE....in NS base browsers you will never be ale to get rid of titlebar..(as of today :D )

neil9999
07-13-2003, 06:46 AM
Sorry, but this still doesn't work. Could you send me the code for the whole button please?

thanks

Neil

Charles
07-13-2003, 07:21 AM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Content-Script-Type" content="text/javascript">
<style type="text/css">
<!--
label {display:block; margin:1em 0em}
input {display:block}
-->
</style>
<form action="">
<div>
<label>Foo<input type="text" name="foo"></label>
<button onclick="alert(this.form.foo.value)">Alert</button>
</div>
</form>

neil9999
07-13-2003, 07:49 AM
Sorry, still doesn't work. This is the code for the whole webpage:

__________________________________________________
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 1</title>
<script LANGUAGE="JavaScript">

function jumpBox(list) {
location.href = list.options[list.selectedIndex].value
}

//created by Neil

function compute(form) {

form.html.value = "<body onunload='alert(\""+form.alert.value+"\");'>";

}

{
}

{

}

<!-- done hiding from old browsers -->
</script>

</head>

<body bgcolor="#C0C0C0">
<p align="center">Alert which appears when you close the page.</p>
<form>
<p align="left">Enter text to be displayed on the alert:&nbsp;</p>
<p align="left"> <input type="text" name="alert" size="55" value="Thanks for visiting this page. Please come again soon!"></p>
<p align="left"><input TYPE="button" VALUE="Generate"
ONCLICK="compute(this.form)"><input type="reset" value="Reset" name="Erase"><button onclick="alert(this.form.alert.value)">Alert</button>
</p>
<p align="left">&nbsp;
</p>
<p align="left">Paste this event handler into your &lt;body&gt; tag:
</p>
<p align="left"><textarea rows="4" name="html" cols="60"></textarea>
</p>
</form>

<p><input type="button" value="Close" name="B3" onClick="javascript:window.close();"><input type="button" value="< Back" name="B4" onclick='window.location="javascriptgenerator3alert.htm";'><input type="button" value="Next >" name="B5" onclick='window.location="javascriptgenerator2.htm";'><input type="button" value="Finish" name="B6" onclick="alert('Complete the wizard before clicking Finish')"></p>
</body>
</html>
__________________________________________________
Please could you ammend this code to make it work?

Thanks,

Neil

neil9999
07-13-2003, 07:52 AM
Also, for my origional second question, I didn't meen make it full screen, i meant just a normal popup without the titlebar.

Thanks,

Neil

Charles
07-13-2003, 08:07 AM
When you give a form element the name "alert" it overwrites the method with the same name.

neil9999
07-13-2003, 08:21 AM
I changed the text box's name to 'text' and it works perfectly now.

Thanks,
Neil