S.Cosmin Posted April 26, 2011 Share Posted April 26, 2011 Hallo guys, I have a problem with my game script, i wanted to make a menu with JS onClick but does't work. When i click on the button he does'n redirect me on that page. This is the code. <?php global $db,$c,$ir, $set; $hc=$set['hospital_count']; $jc=$set['jail_count']; $ec=$ir['new_events']; $mc=$ir['new_mail']; if($ir['hospital']) { print " <div class='menu_hospital'> <object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='170' height='387' title='TheGangsters.ro'> <param name='movie' value='images/flash/header.swf' /> <param name='quality' value='high' /> <param name='wmode' value='Transparent' /> <embed src='images/flash/menu_hospital.swf' quality='high' wmode='transparent' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='170' height='387'></embed> </object> </div>"; } elseif($ir['jail']) { print " "; } else { print " <table cellspacing='1' width='100%'> <tr> <td width='100%' height='550' valign='top'> <table cellpadding='0' cellspacing='0' border='0' class='content_menu_left'> <tr> <td width='148'> <ul class='action_menu'> <li onClick=\"redirect('bank.php')\"><div id=\"menu-sprite-sabotage\" class=\"menu-sprite\"></div><span class=\"action_menu_header\">Sabotaj</span><br>Distruge-ti rivalii!</li> <li onClick='function redirect(a){ location.href=a; }><div id='menu-sprite-hookers' class='menu-sprite'></div><span class='action_menu_header'>Tarfe</span><br>Vezi ce fac tarfele.</li> <li onClick='redirect('armsdealer.php')'><div id='menu-sprite-armsdealer' class='menu-sprite'></div><span class='action_menu_header'>Vanzatorul de arme</span><br>Ia-ti niste scule.</li> <li onClick='redirect('alley.php')'><div id='menu-sprite-alley' class='menu-sprite'></div><span class='action_menu_header'>Aleea</span><br>Fa o ciupeala.</li> </ul> </td> </tr> </table> </div>"; } if($ir['jail'] and !$ir['hospital']) { print "<li> <a class='link1' href='gym.php'>Jail Gym</a></li> <li> <a class='link1' href='hospital.php'>Hospital ($hc)</a></li>"; } else if (!$ir['hospital']) { print "<li> "; } if(!$ir['jail'] ) { print " "; } ?> What can i do guys? Sorry for my bad English. Thank you. :worship: Quote Link to comment Share on other sites More sharing options...
Dave Posted April 26, 2011 Share Posted April 26, 2011 Firstly, you have to function called redirect so calling it is going to do nothing, and why don't you just simply use a link like you've done further down the file? Quote Link to comment Share on other sites More sharing options...
S.Cosmin Posted April 26, 2011 Author Share Posted April 26, 2011 I want to make that with onClick, is more intersting... Can you help me to make this to work? What to change? Quote Link to comment Share on other sites More sharing options...
Danny696 Posted April 26, 2011 Share Posted April 26, 2011 the javascript function doesnt exist Quote Link to comment Share on other sites More sharing options...
S.Cosmin Posted April 26, 2011 Author Share Posted April 26, 2011 So...what can i do to work mister? Quote Link to comment Share on other sites More sharing options...
Danny696 Posted April 26, 2011 Share Posted April 26, 2011 make the function.... Quote Link to comment Share on other sites More sharing options...
Djkanna Posted April 26, 2011 Share Posted April 26, 2011 (edited) function redirect(url) { if (url != 'undefined') window.location = url; } Very basic. Don't use redirects if you can just use an anchor tag, it's pointless. Edited April 26, 2011 by Djkanna Quote Link to comment Share on other sites More sharing options...
S.Cosmin Posted April 27, 2011 Author Share Posted April 27, 2011 Ok mister. If i add that in global_func.php i become a error like: Parse error: parse error, expecting `'&'' or `T_VARIABLE' in C:\xampp\htdocs\global_func.php on line 481 If i add that in mainmenu.php i become this error... Parse error: parse error, expecting `'&'' or `T_VARIABLE' in C:\xampp\htdocs\menu_left.php on line 2 How to fix that mister? Thanks for everything. Quote Link to comment Share on other sites More sharing options...
a_bertrand Posted April 27, 2011 Share Posted April 27, 2011 that's a Javascript function not a PHP one. So it must be in an echo or in a part outside the PHP tags. Quote Link to comment Share on other sites More sharing options...
S.Cosmin Posted April 27, 2011 Author Share Posted April 27, 2011 Ohh...i'm the biggest noob ever :D, i can't do this :| can anyoane with experience to place that function on this code? <?php echo " global $db,$c,$ir, $set; $hc=$set['hospital_count']; $jc=$set['jail_count']; $ec=$ir['new_events']; $mc=$ir['new_mail']; if($ir['hospital']) { print " <div class='menu_hospital'> <object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='170' height='387' title='TheGangsters.ro'> <param name='movie' value='images/flash/header.swf' /> <param name='quality' value='high' /> <param name='wmode' value='Transparent' /> <embed src='images/flash/menu_hospital.swf' quality='high' wmode='transparent' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='170' height='387'></embed> </object> </div>"; } elseif($ir['jail']) { print " "; } else { print " <table cellspacing='1' width='100%'> <tr> <td width='100%' height='550' valign='top'> <table cellpadding='0' cellspacing='0' border='0' class='content_menu_left'> <tr> <td width='148'> <ul class='action_menu'> <ul class='action_menu'><li onClick='redirect('assault.php')'> <div id='menu-sprite-assault' class='menu-sprite'></div> <span class='action_menu_header'>Atac</span><br>Rupe-i curu fraierului.</li><li onClick='redirect('robbery.php')'> <div id='menu-sprite-robbery' class='menu-sprite'></div> <span class='action_menu_header'>Spargere</span><br>Sa spargem ceva.</li><li onClick='redirect('sabotage.php')'> <div id='menu-sprite-sabotage' class='menu-sprite'></div> <span class='action_menu_header'>Sabotaj</span><br>Distruge-ti rivalii!</li><li onClick='redirect('hookers.php')'> <div id='menu-sprite-hookers' class='menu-sprite'></div> <span class='action_menu_header'>Tarfe</span><br>Vezi ce fac tarfele.</li><li onClick='redirect('armsdealer.php')'> <div id='menu-sprite-armsdealer' class='menu-sprite'></div> <span class='action_menu_header'>Vanzatorul de arme</span><br>Ia-ti niste scule.</li><li onClick='redirect('drugdealer.php')'> <div id='menu-sprite-drugdealer' class='menu-sprite'></div> <span class='action_menu_header'>Dealer droguri</span><br>Cumperi si vinzi marfa.</li><li onClick='redirect('buildings.php')'> <div id='menu-sprite-buildings' class='menu-sprite'></div> <span class='action_menu_header'>Cladiri</span><br>Proprietatile tale</li><li onClick='redirect('nightlife.php')'> <div id='menu-sprite-nightlife' class='menu-sprite'></div> <span class='action_menu_header'>Viata de noapte</span><br>Intra si distreaza-te toata noaptea.</li><li onClick='redirect('businesses.php')'> <div id='menu-sprite-businesses' class='menu-sprite'></div> <span class='action_menu_header'>Afacerile tale</span><br>Incepe propria afacere.</li><li onClick='redirect('hospital.php')'> <div id='menu-sprite-hospital' class='menu-sprite'></div> <span class='action_menu_header'>Spital</span><br>Trateaza-te, ametitule!</li><li onClick='redirect('prison.php')'> <div id='menu-sprite-prison' class='menu-sprite'></div> <span class='action_menu_header'>Inchisoare</span><br>Esti curios? Mai bine nu...</li><li onClick='redirect('bank.php')'> <div id='menu-sprite-bank' class='menu-sprite'></div> <span class='action_menu_header'>Banca</span><br>Pune-ti banii in loc sigur.</li><li onClick='redirect('den.php')'> <div id='menu-sprite-den' class='menu-sprite'></div> <span class='action_menu_header'>Magic Shop</span><br>Cumpara-ti talismanul norocos</li><li onClick='redirect('alley.php')'> <div id='menu-sprite-alley' class='menu-sprite'></div> <span class='action_menu_header'>Aleea</span><br>Fa o ciupeala.</li></ul> </ul> </td> </tr> </table> </div>"; } if($ir['jail'] and !$ir['hospital']) { print "<li> <a class='link1' href='gym.php'>Jail Gym</a></li> <li> <a class='link1' href='hospital.php'>Hospital ($hc)</a></li>"; } else if (!$ir['hospital']) { print "<li> "; } if(!$ir['jail'] ) { print " "; } ?> Quote Link to comment Share on other sites More sharing options...
Danny696 Posted April 27, 2011 Share Posted April 27, 2011 You clearly dont know js, may i ask why you would want to javascript a href tag? Quote Link to comment Share on other sites More sharing options...
a_bertrand Posted April 27, 2011 Share Posted April 27, 2011 honestly I don't see really the goal for it... but in your case it simply miss a ' in the script tag Quote Link to comment Share on other sites More sharing options...
S.Cosmin Posted April 27, 2011 Author Share Posted April 27, 2011 Ohh..i want to make the menu like http://www.thecrims.com menu...but i don't know how...:( Quote Link to comment Share on other sites More sharing options...
bineye Posted April 27, 2011 Share Posted April 27, 2011 I'm not going to register just to see the menu, but I'm almost sure it's not JavaScript you need, instead probably CSS. Quote Link to comment Share on other sites More sharing options...
S.Cosmin Posted April 27, 2011 Author Share Posted April 27, 2011 The ingame menu it's like the outgame menu, same menu... can i do this? Mister... Quote Link to comment Share on other sites More sharing options...
Danny696 Posted April 27, 2011 Share Posted April 27, 2011 CSS would actually work better than JS. It shouldnt be too hard to do the menu... Quote Link to comment Share on other sites More sharing options...
a_bertrand Posted April 27, 2011 Share Posted April 27, 2011 I don't see any Javascript needs for a "menu" like the on on the front page of this game. As all the other said, use CSS. Quote Link to comment Share on other sites More sharing options...
S.Cosmin Posted April 27, 2011 Author Share Posted April 27, 2011 Pffff.....i hate CSS&ONCLICK I can't do this :( Quote Link to comment Share on other sites More sharing options...
Danny696 Posted April 27, 2011 Share Posted April 27, 2011 Heres a tip, remove the onclick, theres no need for it, and you dont know what your doing. Learn CSS, and CSS sprites Quote Link to comment Share on other sites More sharing options...
S.Cosmin Posted April 27, 2011 Author Share Posted April 27, 2011 Heres a tip, remove the onclick, theres no need for it, and you dont know what your doing. Learn CSS, and CSS sprites It's work with CSS! Thank you for the tip, thank all of you guys. You solved my problem. You can close the topic if you want. Merci Quote Link to comment Share on other sites More sharing options...
Djkanna Posted April 28, 2011 Share Posted April 28, 2011 I'm glad you managed to achieve what you were hoping for. :) 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.