Jump to content

alert not working - value embed inside div element?


sayedsohail

Recommended Posts

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>

 

Link to comment
Share on other sites

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?

 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.