passegua Posted March 20, 2014 Share Posted March 20, 2014 I am trying to make this script working with a prompt that ask the user which object (screen, location, window) property will show.If I use this code it will works with this:PropriedadesPropriedad ValoravailWidth = 1280availHeight = 800availTop = 0availLeft = 0pixelDepth = 24colorDepth = 24width = 1280height = 800 <body> <h2>Propriedades</h2> <table id="tabla"> <tr><th> Propriedad </th><th> Valor </th></tr> </table> <script type="text/javascript"> var i, tabla = document.getElementById("tabla"); for (i in screen){ tabla.innerHTML += "<tr><td>"+i+" </td><td> = " +screen[i]+ "</td></tr>"; } </script> </body> But If I ask which name with a prompt, then the output is wrong, why? Please Help me! Thanks.PropriedadesPropriedad Valor0 = s1 = c2 = r3 = e4 = e5 = n <body> <h2>Propriedades</h2> <table id="tabla"> <tr><th> Propriedad </th><th> Valor </th></tr> </table> <script type="text/javascript"> name=prompt("¿Que propriedad quiere?"); var i, tabla = document.getElementById("tabla"); for (i in name){ tabla.innerHTML += "<tr><td>"+i+" </td><td> = " +name[i]+ "</td></tr>"; } </script> </body> Quote Link to comment https://forums.phpfreaks.com/topic/287136-how-input-an-object-word-into-a-variable/ Share on other sites More sharing options...
requinix Posted March 20, 2014 Share Posted March 20, 2014 name is just the string "screen". If you want to get the value of window.screen you can also do that with window["screen"]... Quote Link to comment https://forums.phpfreaks.com/topic/287136-how-input-an-object-word-into-a-variable/#findComment-1473397 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.