Closed Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 20

Thread: prompt to to appear after onclick

  1. #1
    freddyw2 is offline Newbie
    Join Date
    Nov 2008
    Posts
    12
    Rep Power
    0

    prompt to to appear after onclick

    Hi there i'm working on this code. id like to enter a form tag so i can have a button thay says "order a drink" then the prompt box appears, rather than it appearing instantly. Im going to have this JS linked to html seperately. What adjustments need to be made to my code? and what will i need in the html file?

    any help would be appreceiated.

    thanks

    Code:
    var mojito ="mojito";
    var caipirnha ="caipirnha";
    var fruit_caipirinha ="fruit caipirinha";
    var iced_tea ="long lsland iced tea";
    var seabreeze ="seabreeze";
    var lynchburg ="lynchburg";
    var esp_martini ="espresso martini";
    var cosmpolitan ="cosmopolitan";
    var belini ="belini";
    var key_west_cooler ="key west cooler";
    
    
    var drink_wanted = prompt ("please enter the cocktail you would like to make")
    if (drink_wanted == mojito) {
    alert ('you have asked for a mojito')
    }
    
    if (drink_wanted == caipirnha) {
    alert ('you have asked for a caipirnha')
    }
    
    if (drink_wanted == fruit_caipirinha) {
    alert ('you have asked for a fruit caipirinha')
    }
    
    if (drink_wanted == iced_tea) {
    alert ('you have asked for a long island iced tea')
    }
    
    if (drink_wanted == seabreeze) {
    alert ('you have asked for a seabreeze')
    }
    
    if (drink_wanted == lynchburg) {
    alert ('you have asked for a fruit lynchburg')
    }
    if (drink_wanted == esp_martini) {
    alert ('you have asked for an espresso martini')
    }
    
    if (drink_wanted == cosmpolitan) {
    alert ('you have asked for a cosmopolitan')
    }
    
    if (drink_wanted == belini) {
    alert ('you have asked for a fruit belini')
    }
    
    if (drink_wanted == key_west_cooler) {
    alert ('you have asked for a key west cooler')
    }
    
    else {
    alert ('sorry, that coktail isn\'t recognised')
    }
    my html is blank at the moment, its basically going to have a list of the cocktails available.

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    Join Date
    Mar 2008
    Location
    The North Pole
    Posts
    13,174
    Blog Entries
    13
    Rep Power
    114

    Re: prompt to to appear after onclick

    Make an order button, then assign some code to its onclick event.

    Quote Originally Posted by Jordan View Post
    Good members, like yourself, stick around and post for ages to come!
    Mr. Xav | Blog | Forums

  4. #3
    freddyw2 is offline Newbie
    Join Date
    Nov 2008
    Posts
    12
    Rep Power
    0

    Re: prompt to to appear after onclick

    thanks, im kind of new to javascript. so i dont really understand what you mean

  5. #4
    Join Date
    Mar 2008
    Location
    The North Pole
    Posts
    13,174
    Blog Entries
    13
    Rep Power
    114

    Re: prompt to to appear after onclick

    In the HTML, you create a button. Then, you set its onclick attribute to some JS code that you have typed. OK?

    Quote Originally Posted by Jordan View Post
    Good members, like yourself, stick around and post for ages to come!
    Mr. Xav | Blog | Forums

  6. #5
    freddyw2 is offline Newbie
    Join Date
    Nov 2008
    Posts
    12
    Rep Power
    0

    Re: prompt to to appear after onclick

    yes i get that but whats the code to hold the prompt?

  7. #6
    Join Date
    Mar 2008
    Location
    The North Pole
    Posts
    13,174
    Blog Entries
    13
    Rep Power
    114

    Re: prompt to to appear after onclick

    HTML Code:
    <input type="button" value="Place Order" onclick="JAVASCRIPT GOES HERE" />

    Quote Originally Posted by Jordan View Post
    Good members, like yourself, stick around and post for ages to come!
    Mr. Xav | Blog | Forums

  8. #7
    freddyw2 is offline Newbie
    Join Date
    Nov 2008
    Posts
    12
    Rep Power
    0

    Re: prompt to to appear after onclick

    thankyou =]

  9. #8
    Join Date
    Mar 2008
    Location
    The North Pole
    Posts
    13,174
    Blog Entries
    13
    Rep Power
    114

    Re: prompt to to appear after onclick

    You are welcome. If you have any more queries then just ask.

    Quote Originally Posted by Jordan View Post
    Good members, like yourself, stick around and post for ages to come!
    Mr. Xav | Blog | Forums

  10. #9
    freddyw2 is offline Newbie
    Join Date
    Nov 2008
    Posts
    12
    Rep Power
    0

    Re: prompt to to appear after onclick

    i acually do have one question.
    ive insterted the <input type="button" value="Place Order" />
    into my html page.
    id rather not have any javascript in there i like it all seperate on another page. how do i make the button bring up the prompt for there?

  11. #10
    Join Date
    Mar 2008
    Location
    The North Pole
    Posts
    13,174
    Blog Entries
    13
    Rep Power
    114

    Re: prompt to to appear after onclick

    In the HEAD section of your HTML page, add this:

    HTML Code:
    <script src="yourscriptfile.js"></script>
    Then, create a new file called yourscriptfile.js (or whatever) and put this code in:

    Code:
    function PlaceOrder()
    {
     //All the rest of the code here.
    }
    You can then call PlaceOrder() in your input tag.

    Quote Originally Posted by Jordan View Post
    Good members, like yourself, stick around and post for ages to come!
    Mr. Xav | Blog | Forums

Closed Thread
Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Preventing onclick() inheritance
    By RHochstenbach in forum JavaScript and CSS
    Replies: 0
    Last Post: 06-02-2011, 03:34 AM
  2. Copy href onClick
    By rsnider19 in forum JavaScript and CSS
    Replies: 1
    Last Post: 11-15-2010, 04:02 PM
  3. PHP Delete onClick
    By Alex_j in forum PHP Development
    Replies: 2
    Last Post: 03-13-2010, 01:32 PM
  4. How To Click An OnClick Button Without Clicking Page?
    By tradingjamie in forum JavaScript and CSS
    Replies: 5
    Last Post: 03-12-2010, 09:01 AM
  5. onClick
    By ezcat in forum PHP Development
    Replies: 2
    Last Post: 01-17-2009, 01:40 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts