i am creating two text areas with id's-id1$i(when,$i=1) and id1$i(when,$i=2)..what i want is that as soon as user changes the text of any of these text areas it should display that text in an alert box.Here is my code:
<?php
$i=1;
while($i)
{
echo '<textarea id="id1$i" onchange=Display("id1$i")></textarea>';
echo "id1$i..<br>";
if($i==2){break;}
$i=2;
}
?>
<input name="Submit" type="submit" value="Submit"/>
<script>
function Display(id1$i)
{
alert(document.getElementById("id1$i").value);
}
</script>
Now when i try running this...the problem is when i enter "one" in the first text area box,it displays "one",that's ok.....but when i enter "two" in the second text area box,it still displays "one"...:mad::mad::mad:...
The only reason dat i can think of why it's hapning lyk dat is the function Display(id1$i) is not taking the value of $i=2...please help!!..
If i use proper names like "id11" and "id12"(i.e i dont use the variable $i anywhere in my code or say if i harcode everythng)..then the code works fine..it displays both "one" "two",respectively..