helloise Posted May 20, 2011 Share Posted May 20, 2011 i have this line of code: <a href="#" id="profilelink" name="profilelink" value="<?php echo $id."/".$block_record;?>" onClick="return viewornot(<?php echo $id; ?>)"><?php echo $uniqueCode; ?></a> so with the onclick i want to pass the id concatenated with a blocked id to my JS: function viewornot() { var val = document.getElementById('profilelink'); var e = confirm('Do you want to view this profile?'); if (e == true) { //for live site window.location.href = "http://www.rainbowcode.net/index.php/profiles/showprofilepersonal?id="+id; return true; } else { //if val contains a 1 then user is blocked //display a message then } return false } the line: var val = document.getElementById('profilelink'); is not giving me what i want it should contain the user id concatenated with a 1(blocked) or 0(not blocked) ($id."/".$blocked_user) can someone help me please? thank you Quote Link to comment https://forums.phpfreaks.com/topic/236931-documentgetelementbyid-problem/ Share on other sites More sharing options...
Adam Posted May 20, 2011 Share Posted May 20, 2011 document.getElementById() returns the DOM object for the element, not the value. You need to use the .value property to get the value, which in your code can be done like: var val = document.getElementById('profilelink').value; Quote Link to comment https://forums.phpfreaks.com/topic/236931-documentgetelementbyid-problem/#findComment-1217916 Share on other sites More sharing options...
helloise Posted May 20, 2011 Author Share Posted May 20, 2011 thank you i sorted it Quote Link to comment https://forums.phpfreaks.com/topic/236931-documentgetelementbyid-problem/#findComment-1217929 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.