/    Sign up×
Community /Pin to ProfileBookmark

Alert Variable

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

to post a comment
JavaScript

7 Comments(s)

Copy linkTweet thisAlerts:
@Khalid_AliJul 13.2003 — 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 ? )
    Copy linkTweet thisAlerts:
    @neil9999authorJul 13.2003 — Sorry, but this still doesn't work. Could you send me the code for the whole button please?

    thanks

    Neil
    Copy linkTweet thisAlerts:
    @CharlesJul 13.2003 — [font=monospace]<!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>[/font]
    Copy linkTweet thisAlerts:
    @neil9999authorJul 13.2003 — 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
    Copy linkTweet thisAlerts:
    @neil9999authorJul 13.2003 — 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
    Copy linkTweet thisAlerts:
    @CharlesJul 13.2003 — [font=georgia]When you give a form element the name "alert" it overwrites the method with the same name.[/font]
    Copy linkTweet thisAlerts:
    @neil9999authorJul 13.2003 — I changed the text box's name to 'text' and it works perfectly now.

    Thanks,

    Neil
    ×

    Success!

    Help @neil9999 spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.20,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...