www.webdeveloper.com
Results 1 to 6 of 6

Thread: function var

  1. #1
    Join Date
    Jul 2013
    Posts
    21

    function var

    i am making a game by hand and i need a LOT of different functions to be called useing the same button and witch one is called depends on where you are in the script but at all times at least 2 to be called when it is pressed

    is there any way i can just change what 1 function dos with a var ? so somthing like

    var stuff = if (somthing == 1){do this}

    function A(){
    stuff
    }

    if not the other problem i am having is
    document.getElementById("button").onclick = dosomthing
    only seems to run 1 thing

    need help ASAP

  2. #2
    Join Date
    Jul 2011
    Posts
    127
    You can use addEventListener or attachEvent for IE to add more than one handler.

    About your first question, I didn't undestand what you mean.

  3. #3
    Join Date
    Jul 2013
    Posts
    21
    sorry but i found a way around it now but i have a new problem
    how would i get a divs scroll bar to be at the bottom when i push a input button?

    i will post a new thing but it takes so long i will also post here

  4. #4
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,259
    Quote Originally Posted by red566 View Post
    sorry but i found a way around it now but i have a new problem
    how would i get a divs scroll bar to be at the bottom when i push a input button?

    i will post a new thing but it takes so long i will also post here
    Since you posted the initial question, how about posting your work-around solution?
    Best way to receive help is to help others when you can.

  5. #5
    Join Date
    Jul 2013
    Posts
    21
    Quote Originally Posted by JMRKER View Post
    Since you posted the initial question, how about posting your work-around solution?
    Best way to receive help is to help others when you can.
    sorry it was just a complete workaround that has now got nothing to do with the question but what ever

    function A(){pos ++}

    if (pos == 1){
    document.getElementById("i").onclick = UpTo1;
    function B(){
    A()
    //what ever in here
    }
    }

    if (pos == 2){
    document.getElementById("id here").onclick = B;
    function C(){
    A()
    //what ever in here
    }
    }

    this thing needs a bigger committing box

  6. #6
    Join Date
    Jul 2013
    Posts
    21
    function A(){pos ++}

    if (pos == 1){
    document.getElementById("i").onclick = B;
    function B(){
    A()
    //what ever in here
    }
    }

    if (pos == 2){
    document.getElementById("id here").onclick = C;
    function C(){
    A()
    //what ever in here
    }
    }

    sorry i mist a bit and you dont seem to be able to edit your own posts
    ps this is a VERY simplified vision of the script

    if any one wants to see the game so far http://www.red566.nf/game.html (it will always be the most up to date V of the game)
    it only works in firefox or chrome right now and it has popups but you dont need them to play

Thread Information

Users Browsing this Thread

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

Posting Permissions

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



Recent Articles