/    Sign up×
Community /Pin to ProfileBookmark

Mad-Libs with Firefox

Hi, I’m new to javascript and computer-code-stuff in general. Just when I thought I had a grasp on a few basic principals, I discovered that web browsers are very picky when it all comes down to it.

What I made is a very simple Mad-Lib generator; the user inputs the words into text boxes and the javascript inserts them into a sentence.

The problem:

[list]

  • [*]

    When used in Firefox, it will not return the sentence.


  • [*]

    When used in Safari, it will return the sentence but instead of posting the 2nd variable, it comes up as ‘undefined’.


  • [*]

    I found no problems with IE.


  • [/list]

    If anyone can tell me what I did wrong, I will be soooooo happy. I can’t figure this one out on my own and I don’t know any humans that can help me out. So, if you can offer any help, please don’t hesitate.

    Thank you

    [URL=http://www.destructiveclothing.com/other/mad_lib.html]Click Here[/URL] to see what I’m talking about.

    to post a comment
    JavaScript

    1 Comments(s)

    Copy linkTweet thisAlerts:
    @JonaOct 20.2004 — [font=trebuchet ms]Define the variables globally, and avoid using "form" as a variable name.[/font]

    <i>
    </i>&lt;script type="text/javascript"&gt;&lt;!--
    var adj, noun;
    function SetAdj(a){adj=a.value;}
    function SetNoun(n){noun=n.value;}
    function SetField(myForm){
    var add = "Do not kill the "+adj+" penguin you smelly "+noun+"!";
    myForm.total.value=add;
    }
    //--&gt;&lt;/script&gt;
    ×

    Success!

    Help @Wart_Hog 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.19,
    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,
    )...