|
 |
|
รับค่าจาก textbox บน popup แล้วให้แสดงใน textarea โดยแสดง ณ ตำแหน่ง cursor |
|
 |
|
|
 |
 |
|
ช่วยด้วยค่ะ ได้โค๊ตจากกระทู้ก่อนหน้านี้ โดยคลิกลิงค์ที่ไฟล์แรก (sample1.html) แล้วจะโชว์ popup (sample2.html) หลังจากนั้นกรอกข้อความบน textbox คลิกที่ลิงค์ของ popup จะแสดงข้อความบน textarea โค๊ตเป็นดังนี้
sample1.html
<form name="form1" method="post" action="">
<script language="JavaScript">
function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features).focus();
}
</script>
<TEXTAREA NAME="viewarea" id="name"></TEXTAREA>
<a href="javascript:MM_openBrWindow('Sample2.html','xxx','scrollbars=no,width=350,height=210')">เลือกข้อมูล</a>
</form>
sample2.html
<script>
function sendtomainform()
{
var targetval = opener.document.all.name.value;
if(targetval == ""){
opener.document.all.name.value = document.all.n.value;
}else{
//opener.document.all.name.value += ",,"+document.all.n.value;
opener.document.all.name.value = opener.document.all.name.value+document.all.n.value;
}
window.close();
}
</script>
<form action="" method="post">
<input name="n" type="text" id="n">
....
<input type="submit" name="Submit" value="Submit" onClick="sendtomainform();">
</form>
สิ่งที่อยากได้ คือ ตอนที่แสดงข้อความให้แสดง ณ ตำแหน่งที่ cursor อยู่ แต่โค๊ตข้างบนมันจะแสดงต่อท้ายเสมอ ลองพยายามแก้แล้ว ยิ่งแก้ก็ยิ่งงง
Tag : JavaScript

|
|
 |
 |
 |
 |
Date :
2011-03-26 21:36:41 |
By :
คุ๊กกี้ |
View :
2543 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
|
|

|
Load balance : Server 03
|