|
|
|
สอบถามเรื่องการรับค่าจาก window.opener รบกวนเข้ามาดูโค้ดหน่อยคับ |
|
|
|
|
|
|
|
Code (PHP)
<?
$sql=$product_id;
$sql = substr($sql,0,-1);
$sql=str_replace(",","','",$sql);
echo $select_detail="SELECT bhl_criterion.*,cbt_prod_type.* FROM ".$CFG->dbname.".bhl_criterion,".$CFG->dbname.".cbt_prod_type WHERE cbt_prod_type.type_id=bhl_criterion.uca_type and company_id='".trim($company_choose)."'";
if($product_id!=''){
echo $select_detail.= "and uca_type in ('$sql')";
}
$query_detail=db_query($select_detail);
$qselect_cbt_prod_type="SELECT cbt_prod_type.type_name,cbt_prod_type.type_id FROM ".$CFG->dbname.".cbt_prod_type WHERE type_status='1' order by cbt_prod_type.type_name";
$rec_cbt_prod_type=db_query($qselect_cbt_prod_type);
$select_date="SELECT dayofmonth(curdate()) as day_select,month(curdate()) as month_select,year(curdate()) as year_select,hour(curtime()) as hour_select,minute(curtime()) as minute_select ";
$query_date=db_query($select_date);
$result_date=mysql_fetch_array($query_date);
$day_select=$result_date["day_select"];
$month_select=$result_date["month_select"];
$year_select=$result_date["year_select"];
$hour_select=$result_date["hour_select"];
$minute_select=$result_date["minute_select"];
$date_start_server=$year_select."-".$month_select."-".$day_select;
$date_end_server=$year_select."-".$month_select."-".$day_select;
?>
<form name="frm_tedit" method="post" action="rm_action.php?mode=tconfig_edit">
<table width="100%" border="1" cellspacing="1" cellspacing="1">
<tr bgcolor="#CCCCFF">
<?if($level=='test'){?>
<td><div align="center"><font color="#335599">คัดลอกข้อมูล </font></div></td>
<?}?>
<td><div align="center"><font color="#335599">ลำดับที่ </font></div></td>
<td><div align="center"><font color="#335599">สินค้า </font></div></td>
<td><div align="center"><font color="#335599">ลูกค้า </font></div></td>
<td><div align="center"><font color="#335599">บริษัท </font></div></td>
<td><div align="center"><font color="#335599">วันที่เริ่มใช้ </font></div></td>
<td><div align="center"><font color="#335599">วันที่สินสุด </font></div></td>
<td><div align="center"><font color="#335599">เปอร์เซนต์สูญหาย </font></div></td>
<td><div align="center"><font color="#335599">หน่วย </font></div></td>
<td><div align="center"><font color="#335599">มูลค่า (บาท/หน่วย) </font></div></td>
<td><div align="center"><font color="#335599">สถานะ </font></div></td>
</tr>
<?
$bgstep=0;
$rows=1;
while($result_detail=db_fetch_array($query_detail)){
if($bgstep=0){
echo "<tr bgcolor=\"#dfdfdf\" onmouseover=\"if (typeof(this.style) != 'undefined') this.style.backgroundColor = '#ffccff'\" onmouseout=\"if (typeof(this.style) != 'undefined') this.style.backgroundColor = ''\">";
$bgstep=1;
}else{
echo "<tr bgcolor=\"#cccccc\" onmouseover=\"if (typeof(this.style) != 'undefined') this.style.backgroundColor = '#FFFFFF'\" onmouseout=\"if (typeof(this.style) != 'undefined') this.style.backgroundColor = ''\">";
$bgstep=0;
}?>
<?if($level=='test'){?>
<td align ="center" ><font color = #335599 face="Arial, Helvetica, sans-serif" size="2" ><input type="checkbox" id="edit<?echo $rows?>" name="edit[<?echo $rows;?>]" onclick="checkblock(this.form,<?echo $rows?>)"></font></td>
<!-- <td><input type="hidd1en" id="status_check<?echo $rows?>" value="0"></td> -->
<?}?>
<td align ="center" ><p align ="center"><font color = #335599 face="Arial, Helvetica, sans-serif" size="2" ><? echo $rows ; ?></font>
<input type="hidden" name="crit_id<?echo $rows?>" size="10" value="<? pv($result_detail["crit_id"] ); ?>">
</td>
<td align ="left" > <font color = #335599 face="Arial, Helvetica, sans-serif" size="2" ><? echo $result_detail["uca_type"]."-->".$result_detail["type_name"]; ?></font>
<input type="hidden" name="uca_type[<?echo $rows;?>]" value="<?echo $result_detail["uca_type"];?>"></td>
<td align="left">
<select id="cust_select<?echo $rows?>" name="cust_select[<?echo $rows;?>]" size="1" Style="color:#0000ff;border-color:#003300;background-color:#ffffff;text-align:center" disabled >
<? $select_custom="SELECT * FROM ".$CFG->dbname_fleet.".rm_custommer WHERE log_status='t' ";
$query_custom=db_query($select_custom);
while($result_custom=db_fetch_array($query_custom)){?>
<option value=<?echo $result_custom["cust_id"];?><?if($result_custom["cust_id"]==$result_detail["cust_id"]){ echo " selected ";}?>>
<?echo $result_custom["custommer"]." ".$result_custom["custommer2"];?>
</option>
<?}?>
</select>
</td>
<td align="left">
<td> <input type="button" name="sel_product" Style='color:#000099;border-color:#ff0000;border-width:1' value="เลือกบริษัท" onclick="myopenwin('frm_list_company.php');">
<input type="hid1den" name="company_choosed<?echo $rows;?>" >
<!-- <input id="company<?echo $rows?>" name="company[<?echo $rows;?>]" size="1" Style="color:#0000ff;border-color:#003300;background-color:#ffffff;text-align:center" disabled > -->
<?//$select_company="SELECT * FROM ".$CFG->dbname.".fac_company WHERE company_status='1'";
// $query_company=db_query($select_company);
// $num_company=db_num_rows($query_company);
// $x=1;
// while($result_company=db_fetch_array($query_company)){?>
<!-- <input type="checkbox" id="company<?echo $rows;?>" name="company[<?echo $rows;?>][<?echo $x;?>]" value="<?echo $result_company["company_id"]?>" size="1" Style="color:#0000ff;border-color:#003300;background-color:#ffffff;text-align:center" onclick="check_value(this.form,<?echo $rows?>,<?echo $x?>)" disabled><?echo $result_company["company_name"]?> -->
<!-- <input type="hidde1n" name="check_status[<?echo $rows;?>][<?echo $x;?>]" value="0"> -->
<?//$x++;?>
<?//}?>
<!-- <input type="hidden" name="num_company[<?echo $rows;?>]" value="<?echo $x;?>"> -->
<?//while($result_company=db_fetch_array($query_company)){?>
<!-- <option value=<?echo $result_company["company_id"];?><?if($result_company["company_id"]==$result_detail["company_id"]){echo " selected ";}?>> -->
<?//echo $result_company["company_name"];?>
<!-- </option> -->
<?//}?>
<!-- </select> -->
<!-- </td> -->
<td align="left">
<input readonly id="date_start<?echo $rows;?>" name="date_start[<?echo $rows;?>]" size="10" value="<?if($result_detail!="0000-00-00"){ pv($result_detail["date_start"]) ;}?>" disabled ><br>
<script language='javascript'>
if (!document.layers) {
document.write("<input type=button onclick='popUpCalendar(this, form.elements[\"date_start[<?echo $rows?>]\"], \"yyyy-mm-dd\")' value='เลือกวัน' style='font-size:11px'>")
}
</script>
</td>
<td align="left">
<input readonly id="date_stop<?echo $rows;?>" name="date_stop[<?echo $rows;?>]" size="10" value="<?if($result_detail!="0000-00-00"){ pv($result_detail["date_stop"]) ;}?>" disabled ><br>
<script language='javascript'>
if (!document.layers) {
document.write("<input type=button onclick='popUpCalendar(this, form.elements[\"date_stop[<?echo $rows?>]\"], \"yyyy-mm-dd\")' value='เลือกวัน' style='font-size:11px'>")
}
</script>
</td>
<td align ="center" ><input type="text" id="crit_lost<?echo $rows;?>" name="crit_lost[<?echo $rows;?>]" value="<? pv($result_detail["crit_lost"]); ?>" size="5" disabled> %</td>
<td align ="center" ><font color = #335599 face="Arial, Helvetica, sans-serif" size="2" >
<select id="unit_lost<?echo $rows?>" name="unit_lost[<?echo $rows;?>]" disabled>
<?config_type_select($result_detail["unit_lost"],"unit_type")?>
</select>
</font></td>
<td align ="center" ><input type="text" id="value<?echo $rows?>" name="value[<?echo $rows;?>]" value="<? pv($result_detail["value"]); ?>" size="5" disabled></td>
<td align ="center" ><font color = #335599 face="Arial, Helvetica, sans-serif" size="2" ><input type="checkbox" id="status<?echo $rows?>" name="status[<?echo $rows;?>]" <?if($result_detail["status"]=="1"){echo "checked";}?> disabled ></font></td>
</tr>
<?$rows++;?>
<?}//end while
?>
<tr><td colspan="6" align="center"><input type="submit" value="บันทึก" onclick="return check_data(this.form,<?echo $rows;?>);"> <input type="reset" value="ยกเลิก"></td></tr>
</table>
<input type="hidden" name="product_id" value="<?echo $product_id?>">
<input type="hidden" name="company_choose" value="<?echo $company_choose?>">
<input type="hidde1n" name="rows" value="<?echo $rows?>">
<input type="hidden" name="fchoose" value="<?echo $fchoose;?>">
<input type="hidden" name="choose" value="<?echo $choose;?>">
</form>
<script language="javascript">
function toconfirm(theform,msgtype){
switch(msgtype){
case "post" :
msgtext = 'กรุณายืนยันการผ่านรายการ' ;
break;
case "save" :
msgtext = 'กรุณายืนยันการบันทึกข้อมูล' ;
break;
case "edit" :
msgtext = 'กรุณายืนยันการแก้ไขข้อมูล' ;
break;
case "delete" :
msgtext = 'กรุณายืนยันการยกเลิกรายการ' ;
break;
default:
msgtext = msgtype ;
break;
}
var is_confirmed = confirm(msgtext);
return is_confirmed;
}
function check_value(form,rows,x){
if(frm_tedit.elements["company["+rows+"]["+x+"]"].checked==true){
frm_tedit.elements["check_status["+rows+"]["+x+"]"].value=1;
}else{
frm_tedit.elements["check_status["+rows+"]["+x+"]"].value=0;
}
}
function checkblock(form,rows){
if(document.getElementById("edit"+rows).checked==true){
//document.getElementById("status_check"+rows).value=1;
//document.getElementById("company"+rows).disabled=false;
document.getElementById("cust_select"+rows).disabled=false;
document.getElementById("date_start"+rows).disabled=false;
document.getElementById("date_stop"+rows).disabled=false;
document.getElementById("crit_lost"+rows).disabled=false;
document.getElementById("unit_lost"+rows).disabled=false;
document.getElementById("value"+rows).disabled=false;
document.getElementById("status"+rows).disabled=false;
for(a=1;a<frm_tedit.elements["num_company["+rows+"]"].value;a++){
frm_tedit.elements["company["+rows+"]["+a+"]"].disabled=false;
}
}else{
//document.getElementById("status_check"+rows).value=0;
//document.getElementById("company"+rows).disabled=true;
document.getElementById("cust_select"+rows).disabled=true;
document.getElementById("date_start"+rows).disabled=true;
document.getElementById("date_stop"+rows).disabled=true;
document.getElementById("crit_lost"+rows).disabled=true;
document.getElementById("unit_lost"+rows).disabled=true;
document.getElementById("value"+rows).disabled=true;
document.getElementById("status"+rows).disabled=true;
for(a=1;a<frm_tedit.elements["num_company["+rows+"]"].value;a++){
frm_tedit.elements["company["+rows+"]["+a+"]"].disabled=true;
}
}
}
/*function check_date(form,rows){
for(a=1;a<frm_tedit.elements["num_company["+rows+"]"].value;a++){
if(frm_tedit.elements["company["+rows+"]["+a+"]"].disabled=true){
}
}
}*/
/*function check_data(form,rows){
if(document.getElementById("status_check"+i).value=="1"){
for(var i=1;i<=rows;i++){
if(document.getElementById("crit_lost"+i).value=='' || document.getElementById("value"+i).value=='' ){
alert('กรุณากรอกข้อมูลให้ครบถ้วน');
return false;
}else{
return toconfirm(this,'save');
}
}
}
}*/
/* function check_data(form){
if(document.frm_tedit.status.checked==true){
if(document.frm_tedit.date_start_value.value=='' || document.frm_tedit.date_stop_value.value=='' || document.frm_tedit.crit_lost_value.value =='' || document.frm_tedit.values.value==''){
alert('กรุณากรอกข้อมูลให้ครบถ้วน');
return false;
}else{
return toconfirm(this,'save');
}
}
}*/
</script>
Code (PHP)
<?
include("../application.php");
?>
<form method="post" name="choose_company">
<table width="95%" border="0" cellspacing="1">
<tr>
<td height="25" bgcolor="#FF9966" colspan="3"><font color="#330066" size="3" face="Microsoft Sans Serif"> เลือกบริษัท</font></td>
</tr>
</table>
<table width="95%" border="0" bgcolor="#FFFFFF" cellspacing = "0">
<tr>
<td valign ="top" align ="center" ><font color = #000000 face="Arial, Helvetica, sans-serif" size="2" >ลำดับ</font></td>
<td valign ="top" align ="center" ><font color = #000000 face="Arial, Helvetica, sans-serif" size="2" >บริษัท</font></td>
<td valign ="top" align ="center" ><font color = #000000 face="Arial, Helvetica, sans-serif" size="2" >Action</font></td>
</tr>
<?
$select_company="SELECT * FROM ".$CFG->dbname.".fac_company WHERE company_status='1'";
$query_company=db_query($select_company);
$num_company=db_num_rows($query_company);
$i=0;
$bgstep=0;
while($result_company=db_fetch_array($query_company)){
$i++;?>
<? if ($bgstep ==0){
echo "<tr bgcolor=\"#CCCCFF\" onmouseover=\"if (typeof(this.style) != 'undefined') this.style.backgroundColor = '#D7D8D9'\" onmouseout=\"if (typeof(this.style) != 'undefined') this.style.backgroundColor = ''\">";
$bgstep = 1;
}else{
echo "<tr bgcolor=\"#FFFFFF\" onmouseover=\"if (typeof(this.style) != 'undefined') this.style.backgroundColor = '#ffff00'\" onmouseout=\"if (typeof(this.style) != 'undefined') this.style.backgroundColor = ''\">";
$bgstep= 0;
}
?>
<td align ="center" ><font color = #335599 face="Arial, Helvetica, sans-serif" size="2" ><? echo $i; ?></font></td>
<td align ="left" ><font color = #335599 face="Arial, Helvetica, sans-serif" size="2" ><? echo $result_company["company_name"]; ?></font></td>
<td align="center">
<input type="checkbox" name="check<?echo $i;?>" id="check<?echo $i;?>" value="" onclick="check_value(this.form);">
<input type="hidden1" name="company_id_choose<?echo $i;?>" id="company_id_choose<?echo $i;?>" value="<?echo $result_company["company_id"]?>">
</td>
<?if($num_company==0){?>
<tr><td width="180" align='center'>ไม่มีข้อมูล</td></tr>
<?}?>
<?}//end while?>
<tr align="right" bgcolor='#FFFF99'>
<input type="hidden" name="num_company" value="<?echo $num_company?>">
<input type="hidden1" name="check_all" value="0">
<!-- <INPUT TYPE="hidden" name="list" value=""> -->
<td colspan="6" align="right"><a title="เลือก / ไม่เลือกทั้งหมด" href="#" onclick="choose_company.list_company.value='';setCheckboxes(this.form);"><font color="#000099">เลือก / ไม่เลือกทั้งหมด</font></a></td>
</tr>
<tr align='right' bgcolor='#FF9966'>
<td colspan="6" align='right'><a title="ต่อไป" href="#" onclick="<?for($i=1;$i<=$num_company;$i++){ echo "if(choose_company.check".$i.".value!=0) choose_company.list_company.value+=(choose_company.check".$i.".value+',');"; } ?> window.opener.frm_tedit.company_choosed.value=choose_company.list_company.value;self.close();">NEXT>>></a>
<INPUT TYPE="hidden" name="list_company" value="">
</td>
</tr>
<script language="JavaScript">
function check_value(form){
check=0;
for(var i=1;i<=document.choose_company.num_company.value;i++){
if(document.getElementById("check"+i).checked==true){
document.getElementById("check"+i).value=document.getElementById("company_id_choose"+i).value;
//alert(document.getElementById("check"+i).value);
check++;
}
}
if(check>0){
form.check_all.value=1;
}else{
form.check_all.value=0;
}
}
function setCheckboxes(form){
check=0;
for(var i=1;i<=document.choose_company.num_company.value;i++){
if(document.choose_company.check_all.value==1){
document.getElementById("check"+i).checked=false;
document.getElementById("check"+i).value="";
}else{
document.getElementById("check"+i).checked=true;
document.getElementById("check"+i).value=document.getElementById("company_id_choose"+i).value;
check++;
}
}
if(check>0){
document.choose_company.check_all.value=1;
}else{
document.choose_company.check_all.value=0;
}
}
</script>
Tag : PHP, JavaScript
|
|
|
|
|
|
Date :
2010-09-26 17:03:00 |
By :
nut_ch31 |
View :
2967 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ผมมีปัญหาตรงการส่งค่า ชื่อบริษัทมายังฟอร์มแรกครับ
อยากถามว่าตรง form แรก ตรง onclick="myopenwin('frm_list_company.php')
ตรงนี้ผมจะให้เลือกบริษัทโดยเลือกไปยังอีกฟอร์มครับ
ผมจะเก็บตัวแปลไว้เป็น <input type="hid1den" name="company_choosed<?echo $rows;?>" >
ซึ่งจะให้เก็บข้อมูลในแต่ล่ะแถวถ้ามีเลือกบริษัท
ส่วน form สอง ตรง window.opener.frm_tedit.company_choosed.value=choose_company.list_company.value;self.close()
ซึงผมต้องการให้ส่งค่า ให้เข้าไปยัง formแรก โดยให้เข้าไปยัง แถวที่ถูกต้อง อยากทราบว่าตรง window.opener.frm_tedit.company_choosed.value=choose_company.list_company.value;self.close()
จะใส่ให้มันรู้จัก $rows ในลักษณะใดครับ
ขอบคุณมากครับ
|
|
|
|
|
Date :
2010-09-26 17:10:29 |
By :
nut_ch31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|