VFDinc Posted November 10, 2011 Share Posted November 10, 2011 Ok, You guys have been great help, and I am learning a lot. I am making a social RPG game, and now I am trying to show the opponents information in a textbox after the player selects an opponent from a drop down list. I have no problem passing the array to the textarea, but I would like to format the data that is presented in the textarea. For example right now I just show Name, class, and level. I want to show in the textarea like this: Name: Fitch Class: Thief Level: 15 instead of: Name: Fitch Class: Thief Level: 15 Also I would like to retain Name, Class, and Level as variables, once the player finds an opponent he wants to fight. I will use Name, Class, and Level again. <script type='text/javascript'> function select_opponent() { var opponent_stats = document.getElementById('opponent').value; document.getElementById('opponent_description').value = opponent_stats; } </script> mysql_connect(); mysql_select_db('sok'); $result = mysql_query('select * from sokopps'); $options=""; while ($row=mysql_fetch_array($result)) { $Class=$row["Class"]; $Name=$row["Name"]; $Level=$row["Level"]; $OppStats = "Name:".$Name ." Class: ". $Class ." Level: ". $Level; $options.="<OPTION VALUE=\"$OppStats\">".$Name; } ?> <strong>Select Opponent:</strong> <select id='opponent' name='opponent' onChange='select_opponent();'> <OPTION VALUE=0>Choose your opponent <?=$options?> </SELECT> </div> <div id="apOppInfo"> <div id="apOppStats"><textarea id='opponent_description' name='opponent_description'> </textarea></div> <div id="apOppImage"></div> </div> <div id="apStratList"> <?php Quote Link to comment Share on other sites More sharing options...
Psycho Posted November 10, 2011 Share Posted November 10, 2011 Moved this to the JS forum,but really this could be solved many different ways. The easiest is to simply to add a line break in the values. $OppStats = "Name:{$Name}\nClass: {$Class}\nLevel: {$Level}"; Quote Link to comment Share on other sites More sharing options...
VFDinc Posted November 10, 2011 Author Share Posted November 10, 2011 That worked great. I used </br> instead,and for some reason never tried /n, even though I knew what it does. I assumed if </br> didn't work, /n wouldn't work. Assumption got me again. Thanks! 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.