rauldv Posted May 18, 2014 Share Posted May 18, 2014 I'm trying to make a game for a fixed number of people. In the beginning i would get there names out of a mysql database. Then they can select there name and play. So there score is saved by there name. So i have a php file where i generate a combobox with the list of people in. But when i change the selected name, i will catch that name in my javascript file. but everytime i get this error: Uncaught ReferenceError: showUser is not defined Does somebody know what i am doing wrong here?game.module( 'game.main').body(function() {game.addAsset('logo.png');SceneGame = game.Scene.extend({ backgroundColor: 0xb9bec7, init: function() { var div = document.createElement("div"); div.style.width = "500px"; div.style.height = "500px"; div.style.background = "red"; div.style.color = "blue"; document.body.appendChild(div); if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else { // code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { div.innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","/test/src/php/test.php",true) xmlhttp.send(); }, showUser: function(stre){ console.log(stre); }});game.start();});<?php$con=mysqli_connect("myhost","myuser","mypassw","mybd");if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error();}$result = mysqli_query($con,"SELECT * FROM highscore"); echo '<select name="drop_2" id="drop_2" onchange="showUser()"> <option value=" " selected="selected">Choose one</option>';while($row = mysqli_fetch_array($result)) { echo '<option value="'.$row['groupId'].'">'.$row['group'].'</option>'; } echo '</select>'; mysqli_close($con);?> Quote Link to comment Share on other sites More sharing options...
enpu Posted May 19, 2014 Share Posted May 19, 2014 Try game.scene.showUser(); rauldv 1 Quote Link to comment Share on other sites More sharing options...
rauldv Posted May 26, 2014 Author Share Posted May 26, 2014 thnx, this helped! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.