Expected identifier ช่วยแนะนำด้วยครับ

index.php

<form name="form1">
<table>
<tr>
<td>
<input type="text" name="txtCustomer1">
<a href="#" OnClick="window.open('addCustomer.php?L=txtCustomer1','null','width=850,height=800,menubar=no,toolbar=no,scrollbars=yes,statusbar=yes,resizable=yes')" style="cursor:hand; text-decoration:none;">+</a>
</td>
</tr>
</table>
</form>


addCustomer.php

<script language="javascript">
function sendValue(name,txtLocation)
   {
    alert (txtLocation);
    //alert (name);
    window.opener.document.form1.txtLocation.value = name;
    window.close();
   }
</script>


<table width="1024" border="0" cellpadding="0" cellspacing="0" class="tbRight">
 <tr >
  <th class="thRight" align="left">No</th>
  <th class="thRight" align="left">Name</th>
  <th class="thRight" align="left">Address</th>
  <th class="thRight" align="left">Telephone</th>
  <th class="thRight" align="left">Fax</th>
 </tr>
 <?php
 $sql = "select * from tb_customer";
 $query=mssql_query($sql);
 $i="1";
 while ($row=mssql_fetch_array($query)){
 ?>
 <tr onClick="JavaScript:sendValue('<?=$row['cusName'];?>','<?=$_GET['L'];?>')" style="cursor:hand;">
  <td class="tdRight"><?=$i?></td>
  <td class="tdRight"><?=$row['cusName'];?></td>
  <td class="tdRight"><?=$row['cusAddress'];?></td>
  <td class="tdRight"><?=$row['cusTel'];?></td>
  <td class="tdRight"><?=$row['cusFax'];?></td>
 </tr>
 <?php
 $i=$i+1;
 }//end sql
 ?>
</table>

เกิด Error ตรง
txtLocation
ตอนที่ alert txtLocation ออกมา ก็โชว์ txtCustomer1 แต่ไม่ยอมส่งค่า name กลับไปที่ txtCustomer1
msg error "window.opener.document.form1.txtLocation is null or not an object"
ผมจะต้องประกาศ txtLocation ยังไงครับ ช่วยแนะนำทีครับ
23 ม.ค. 2553 2 4,903

ไม่รู้ว่าจะทำอะไร ดูไม่ออก

function sendValue(name,txtLocation)
   {
    alert (txtLocation);
    
//alert (name);
    window.opener.document.form1.txtLocation.value = name;
    window.close();
   }


txtLocation ทั้ง 2 ตัวนี้เธอหมายถึงตัวเดียวกันหรือเปล่า ถ้าใช่ แสดงว่ามันผิด

form1.txtLocation

อันนี้ txtLocation จะต้องเป็น name เท่านั้น

ถ้าไม่สามารถอ้างถีงได้ ให้ลองกำหนดเป็น id ดูครับ และ หาด้วย document.getElementById 
#1

ขออธิบายเพิ่มเติมครับ
คือ พอกดปุ่ม add (เครื่องหมาย +) from1 (index.php) จะเปิด popup addCustomer.php ขึ้นมาครับแล้วผมก็เลือกรายชื่อลูกค้า
รายชื่อลูกค้าที่ถูกเลือกก็จะส่งค่ากลับมาที่ txtCustomer1 (index.php) ครับ 

function sendValue(name,txtLocation)
   {
    alert (txtLocation);
    
//alert (name);
    window.opener.document.form1.txtLocation.value = name;
    window.close();
   }


txtLocation 2 ตัวนี้เปงตัวเดียวกันครับ ^^

ผมจะลองทำตามที่พี่แนะนำดูครับ

ขอบคุณมากครับที่ช่วยชี้แนวทาง
#2
ความคิดเห็น
ไฟล์อัปโหลด ชนิด jpg, jpeg ขนาดไฟล์ไม่เกิน 1024
^