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>

 

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?

 

 

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.