sayedsohail Posted July 5, 2007 Share Posted July 5, 2007 Hi everyone, I am just wondering, how to alert recno to user from input field which is embed inside the <div> element.? 1. alert user with recno value from the input field which is embed inside the div. PHP Code: <?php echo "<div onclick=\"highlight(this)\">$firstname <input type='hidden' value="$recno" onclick=\"recno(this)\"></div>" ?> <script> function recno(A); {alert (a); } </script> Quote Link to comment Share on other sites More sharing options...
micah1701 Posted July 5, 2007 Share Posted July 5, 2007 you have a lot of issues here. 1) you can't add an onclick event to a hidden input (nor very easily to a div as you have done) 2) you are calling a function "highlight()" which may or may not exist, you didn't post code for it. 3) in your javascript function remove the semicolon after "function recno(A)" 4) you pass the variable to your function as an uppercase 'A' but then in your alert() statement, you use a lower case 'a' -- which is an unassigned variable (they are case sensitive) there's more, but right now you seem to be a little over your head so i'll leave it at that. perhaps you could better explain what you're trying to do? Quote Link to comment Share on other sites More sharing options...
sayedsohail Posted July 6, 2007 Author Share Posted July 6, 2007 well the only thing i wish to achieve is dispaly $firstname, which works fine. Now I got to capture the $i value from hidden field embed inside the div and create a alert, that's all. for($i=1;$i<8;$i++) echo "<div onclick=\"highlight(this)\"> $firstname<input type='hidden' value='$i' "></input></div>"; <script> function highlight(A) { alert (A); } </script> I hope this is bit clearer than the previous post. 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.