user4fun Posted June 5, 2009 Share Posted June 5, 2009 <script type="text/javascript"> var params =""; var objValue = document.getElementById("MyNumber"); var objUser = document.getElementById("username_chk"); var objPass = document.getElementById("password_chk"); var params = "?choice=" + objValue + "&username_chk=" + objUser + "&password_chk=" + objPass;document.write(params);document.write("<br />");</script>password <input type="hidden" id="password_chk" value ="5753020">user <input type="hidden" id="username_chk" value ="afifiman1">ans <input type="hidden" id="MyNumber" value ="43467"> var params always end up being ?choice=null&username_chk=null&password_chk=nullwhy is that? Link to comment Share on other sites More sharing options...
jesh Posted June 6, 2009 Share Posted June 6, 2009 It looks like you're trying to access the values of the elements before they exist on the page.Try this: password <input type="hidden" id="password_chk" value="5753020">user <input type="hidden" id="username_chk" value="afifiman1">ans <input type="hidden" id="MyNumber" value="43467"><script type="text/javascript">var params = "";var objValue = document.getElementById("MyNumber");var objUser = document.getElementById("username_chk");var objPass = document.getElementById("password_chk");var params = "?choice=" + objValue.value + "&username_chk=" + objUser.value + "&password_chk=" + objPass.value;document.write(params);document.write("<br />");</script> Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.