unable to pass php variable in script function

Phantom

New Member
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:\[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="http://stackoverflow.com/questions/15913693/Submit"/><script>function Display(id1$i) { alert(document.getElementById("id1$i").value); }</script>\[/code\] 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..
 
Top