1. #1
    Dellipop's Avatar
    Registered
    30/12/09
    Location
    Brugge
    Posts
    140
    iTrader
    0
    Mentioned
    0 Post(s)
    Reputation
    0/0

    JQuery Console Game

    heb wat problemen met simpele console game, als ik help intik als command doet hij niks...

    index.html code
    Code:
    <html>
    <head>
    <script type="text/javascript" src="scripts/jquery.js"></script>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Console Game Project</title>
    </head>
    <body>
    
    <div id="console">
    
    <p id="message_startgame">Welcome to Nieli's game! To control the game you must type in commands</p>
    
    <p id="area_northcorridor">You are in the north door. There is a sword on the ground.</p>
    
    <p id="message_help" style="display: none;">Here is a list of commands</p>
    
    <!--
    PLACEHOLDER: THIS IS WHERE EVERYTHING WILL BE INSERTED BEFORE
    -->
    
    <div id="placeholder"></div>
    
    <form onsubmit="return false;">
    <input type="text" size="50" autofocus="autofocus" id="command_line" />
    </form>
    
    </div>
    
    <script type="text/javascript" src="scripts/game.js"></script>
    
    </body>
    </html>
    game.js code
    Code:
    //been to variables
    beentonorthdoor = true;
    //
    //Item variable
    sword = false;
    //
    //Current room
    currentroom = "n_corridor";
    //
    
    $(document).ready(function() {
    	$("form").submit(function() {
    		var input = $("#command_line").val();
    		
    		if (input == "help") {
    			$("#message_help").clone().insertBefore("#placeholder").fadeIn(1000);
    		}
    		
    		$("#command_line").val("");
    	}};	
    }};
    Denk dat de fout hier ergens zit:

    Code:
    $(document).ready(function() {
    	$("form").submit(function() {
    		var input = $("#command_line").val();
    		
    		if (input == "help") {
    			$("#message_help").clone().insertBefore("#placeholder").fadeIn(1000);
    		}
    		
    		$("#command_line").val("");
    Maar kvind hem niet :S

    Kan iemand helpen
    no votes   Reply With Quote Reply With Quote

  2. #2
    Zero Grav's Avatar
    Registered
    06/06/04
    Location
    Bilzen
    Posts
    8,805
    iTrader
    18 (100%)
    Mentioned
    0 Post(s)
    Reputation
    42/128
    Ge hebt twee keer }}; geschreven in plaats van });.

    Is op 2 seconden gespot als ge een Javascript debugger gebruikt. Bij Firefox bijvoorbeeld Firebug en bij Chrome/Safari rechtermuisklikken, inspect element en dan de console selecteren.
    no votes   Reply With Quote Reply With Quote

  3. #3
    Dellipop's Avatar
    Registered
    30/12/09
    Location
    Brugge
    Posts
    140
    iTrader
    0
    Mentioned
    0 Post(s)
    Reputation
    0/0
    Oh, dom van me =p werkt nu thx
    no votes   Reply With Quote Reply With Quote

Posting Permissions

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

Log in

Log in