สับสนกับการใช้ form สับสนกับการใช้form คือต้องการให้ผลจากการคำนวณแสดงออกมาเป็นกราฟก่อน save ลง db
สับสนกับการใช้form
คือต้องการให้ผลจากการคำนวณแสดงออกมาเป็นกราฟก่อน save ลง db ลองแก้codeอยู่นานไปต่อไม่ได้เลย ช่วยหน่อยครับแก้ตรงไหนดี Code (PHP)
<?php
</style>
<script language="JavaScript">
function check_number(ch){
var len, digit;
if(ch == " "){
return false;
len=0;
}else{
len = ch.length;
}
for(var i=0 ; i<len ; i++)
{
digit = ch.charAt(i)
if(digit >="0" && digit <="9"){
;
}else{
return false;
}
}
return true;
}
function checkvalue()
{
if(!check_number(document.frmDataEntry.spcMc.value) || document.frmDataEntry.spcMc.value == "" )
{
alert('Please select MC number first.');
return false;
}
if(!check_number(document.frmDataEntry.spcMax.value) || document.frmDataEntry.spcMax.value == "" )
{
alert('Max : Please Enter Number');
return false;
}
if(!check_number(document.frmDataEntry.spcMean.value) || document.frmDataEntry.spcMean.value == "" )
{
alert('Mean : Please Enter Number');
return false;
}
if(!check_number(document.frmDataEntry.spcMin.value) || document.frmDataEntry.spcMin.value == "" )
{
alert('Min : Please Enter Number');
return false;
}
if(!check_number(document.frmDataEntry.spcPressur.value) || document.frmDataEntry.spcPressur.value == "" )
{
alert('Pressure : Please Enter Number');
return false;
}
if(!check_number(document.frmDataEntry.spcTemp.value) || document.frmDataEntry.spcTemp.value == "" )
{
alert('Temp : Please Enter Number');
return false;
}
if(!check_number(document.frmDataEntry.en.value) || document.frmDataEntry.en.value == "" )
{
alert('EN : Please Enter Number');
return false;
}
}
</script>
<script language="JavaScript1.2">
<!--
window.moveTo(0,0);
if (document.all) {
top.window.resizeTo(screen.availWidth,screen.availHeight);
}
else if (document.layers||document.getElementById) {
if (top.window.outerHeight<screen.availHeight||top.window.outerWidth<screen.availWidth){
top.window.outerHeight = screen.availHeight;
top.window.outerWidth = screen.availWidth;
}
}
//-->
</script>
</head>
<?
include('../includes/ww.php');
?>
<div class="spcMain">
<table width="100%" cellspacing="0" bordercolor="#ACA899">
<tr>
<td width="38%" valign="top"><table width="100%" cellspacing="0">
<tr>
<td colspan="2" class="title_yello blod"> </td>
<td width="18%" class="title_yello blod">Data Entry </td>
</tr>
<tr>
<td width="20%" class="title_yello">Department</td>
<td width="62%" class="white">Tape & Reel</td>
<td> </td>
</tr>
<tr>
<td class="title_yello"> </td>
<td class="white">Peel Back Force Test - Norminal the Best</td>
<td> </td>
</tr>
<tr>
<td class="title_yello"> </td>
<td class="white">99.10% - 100% Grams</td>
<td> </td>
</tr>
<tr>
<td class="title_yello"> </td>
<td class="white"> </td>
<td> </td>
</tr>
<tr>
<td class="title_yello"> </td>
<td class="white"> </td>
<td> </td>
</tr>
</table></td>
<td width="62%" valign="top"><table width="100%" cellspacing="0">
<tr>
<td width="12%" colspan="2" valign="top">
<form name="frm1" method="post">
<table width="100%" cellspacing="0">
<tr>
<td width="26%" align="right" class="white">WW</td>
<td width="74%"><?
if (!$getqdate) $getqdate=$qdate;
?>
<input name="getqdate" type="text" id="ww" value="<?=$getqdate;?>"></td>
</tr>
<tr>
<td align="right" class="white">MC</td>
<td><?
$db_name = 'product';
include('../../include/dbconnect.php');
$results_mc = mysql_query("SELECT * FROM tblmc");
?>
<select name="mc">
<option>
<?=$mc;?>
</option>
<?
while ($data_mc = mysql_fetch_array($results_mc))
{
?>
<option>
<?=$data_mc["mc"]?>
</option>
<? } ?>
</select></td>
</tr>
<tr>
<td align="right" class="white">Year</td>
<td><select name="sel_year">
<option>
<?=$sel_year;?>
</option>
<option>
<?=date("y",mktime(date("h"),date("i"),date("s"),date("m"),date("d"),date("y")+1));?>
</option>
<option>
<?=date("y",time());?>
</option>
</select></td>
</tr>
<tr>
<td align="right" class="white"> </td>
<td><input name="view" type="submit" id="view" value="View"></td>
</tr>
</table>
</form>
</td>
<td colspan="4"> </td>
</tr>
</table></td>
</tr>
</table>
<div class="spcHeader">MIPT TR OEE MACHINE PERFORMANCE</div>
<div class="nf" align="center">
<p>
<?
$spcMin=$_POST['spcMin'];
$spcMax=$_POST['spcMax'];
if($spcMin!=""and$spcMax!="")
{
$divide = round($spcMax/$spcMin*100,2 );
}
?>
<? //----------------------------------------
$db_name = 'mychart';
if (!(@mysql_select_db($db_name)))
{
echo("<p>Unable to locate the $db_name database.</p>");
exit();
}
//----------------------------------
$year = date("y",time())+1;
if (strlen($year)==1) $year="0$year";
if (!$sel_year) $sel_year = $year;
if (!$mc) $mc=48;
$results = mysql_query("SELECT * FROM tblspc where (qdate like '%$getqdate') AND (mc like '%$mc') AND (qyear like '%$sel_year') order by id asc LIMIT 0 , 12 ");
$numrows = mysql_num_rows($results);
?>
</p>
</div>
<div class="spcChart">
<div align="right">
<table width="200" border="1" align="left">
<tr>
<td><form id="form1"name="form1" method="post"action="view.php">
<table width="100%" cellspacing="0">
<tr>
<td width="14%" align="right" class="white style3">en<span class="style5">EN.</span></td>
<td width="12%"><input name="en" type="text" id="en" maxlength="6" /></td>
<td width="14%" align="right" class="white style3">TEMP</td>
<td width="12%"><input name="spcTemp" type="text" id="spcTemp" maxlength="3" /></td>
<td width="48%"> </td>
</tr>
<tr>
<td align="right" class="white style4 style3">SO / so<span class="style3">Batch #</span></td>
<td><input name="so" type="text" id="so" /></td>
<td align="right" class="white style3">PRESSpressURE</td>
<td><input name="spcPressur" type="text" id="spcPressur" maxlength="2" /></td>
<td> </td>
</tr>
<tr>
<td align="right" class="white style4 style3">minMIN</td>
<td><input type="text" name="spcMin" id="spcMin"value="<?=$spcMin;?>"maxlength="6"/></td>
<td align="right" class="white style3">Out of UCL</td>
<td align="right"><span class="redBox">2</span></td>
<td> </td>
</tr>
<tr>
<td align="right" class="white style4 style3">mean<span class="style3">MEAN</span></td>
<td><input type="text" name="spcMax" id="spcMax"value="<?=$spcMax;?>"maxlength="6"/></td>
<td align="right" class="white style3">Out of LCL</td>
<td align="right"><span class="redBox">1</span></td>
<td> </td>
</tr>
<tr>
<td align="right" class="white style4 style3">maxMAX</td>
<td><span class="style3">
<input name="spcMean" type="text" id="spcMean" value="<?=$divide;?>"maxlength="4" />
</span></td>
<td><span class="style3">
<input type="submit" name="submit" id="view2" value="value""คำนวนค่า spcMin="spcMin" spcMax="spcMax""/>
</span></td>
<td><input type="submit" name="Submit" value="Save" /></td>
<td> </td>
</tr>
</table>
</form></td>
</tr>
</table>
<?
include("../Includes/FusionCharts.php");
$strXML = "<graph bgcolor='336699' caption='' numberPrefix='' formatNumberScale='99.10' rotateValues='1' decimalPrecision='2' rotateNames='1' showValues='99.10' yaxismaxvalue='100' yaxisminvalue='55' canvasBgColor='444444' canvasBorderColor='FFFFFF' chartTopMargin='30' chartLeftMargin='20' chartRightMargin='30' divlinecolor='FFFFFF' divLineThickness='1' baseFontColor='000000' outCnvBaseFontColor='FFFFFF' numdivlines='6' showShadow='0' >";
$strCategories = "<categories>";
$strDataPrev = "<dataset seriesName='MACHINE#$mc' color='FF9900' anchorBorderColor='FFFFFF' anchorBgColor='FF8000' anchorSides='4' lineThickness='2' >";
while ($data = mysql_fetch_array($results))
{
$strCategories .= "<category name='" . $data['qdate'] . "' />";
$strDataPrev .= "<set value='" . $data['spcmean'] . "' />";
}
$strCategories .= "</categories>";
$strDataPrev .= "</dataset>";
$strDataucl = "<trendlines>";
$strDataucl .= "<line startValue='99.75' color='66cc33' displayValue='UCL' thickness='2' showOnTop='1'/>";
$strDataucl .= "</trendlines>";
$strDatalcl = "<trendlines>";
$strDatalcl .= "<line startValue='99.65' color='FF6600' displayValue='LCL' thickness='2' showOnTop='1'/>";
$strDatalcl .= "</trendlines>";
$strXML .= $strCategories . $strDataPrev . $strDataucl . $strDatalcl . "</graph>";
echo renderChartHTML("../Charts/FCF_MSLine.swf", "", $strXML, "myNext", 850, 550, false);
?>
Tag : - - - -
Date :
2009-08-19 06:28:38
By :
pongsatorn06
View :
1199
Reply :
3
ผมคิดว่า กราฟควรจะเป็น javascript เพราะมันจะได้เป็น dynamic ขณะเปลี่ยนการแสดงผลก็ทำได้ก่อนซับมิตฟอร์ม
วิธีการก็คือ แสดงกราฟก่อนบันทึกแค่นั้นเอง
Date :
2009-08-19 07:52:41
By :
pjgunner
กราฟเป็น javascript อยู่แล้วครับ แต่จะให้แสดงผลกราฟก่อนบันทึก แก้ตรงส่วนไหนอะครับ ยังไม่เข้าใจ หมายถึงให้เอาform
<td><form id="form1"name="form1" method="post"action="view.php">
<table width="100%" cellspacing="0">
<tr>
<td width="14%" align="right" class="white style3">en<span class="style5">EN.</span></td>
<td width="12%"><input name="en" type="text" id="en" maxlength="6" /></td>
<td width="14%" align="right" class="white style3">TEMP</td>
<td width="12%"><input name="spcTemp" type="text" id="spcTemp" maxlength="3" /></td>
<td width="48%"> </td>
</tr>
<tr>
<td align="right" class="white style4 style3">SO / so<span class="style3">Batch #</span></td>
<td><input name="so" type="text" id="so" /></td>
<td align="right" class="white style3">PRESSpressURE</td>
<td><input name="spcPressur" type="text" id="spcPressur" maxlength="2" /></td>
<td> </td>
</tr>
<tr>
<td align="right" class="white style4 style3">minMIN</td>
<td><input type="text" name="spcMin" id="spcMin"value="<?=$spcMin;?>"maxlength="6"/></td>
<td align="right" class="white style3">Out of UCL</td>
<td align="right"><span class="redBox">2</span></td>
<td> </td>
</tr>
<tr>
<td align="right" class="white style4 style3">mean<span class="style3">MEAN</span></td>
<td><input type="text" name="spcMax" id="spcMax"value="<?=$spcMax;?>"maxlength="6"/></td>
<td align="right" class="white style3">Out of LCL</td>
<td align="right"><span class="redBox">1</span></td>
<td> </td>
</tr>
<tr>
<td align="right" class="white style4 style3">maxMAX</td>
<td><span class="style3">
<input name="spcMean" type="text" id="spcMean" value="<?=$divide;?>"maxlength="4" />
</span></td>
<td><span class="style3">
<input type="submit" name="submit" id="view2" value="value""คำนวนค่า spcMin="spcMin" spcMax="spcMax""/>
</span></td>
<td><input type="submit" name="Submit" value="Save" /></td>
จากตรงนี้มาวางไว้หลังกราฟ ใช่ไหมครับ ขอguideให้อีกนิด ขอบคุณล่วงหน้าครับ
Date :
2009-08-19 13:46:40
By :
pong
ต้องการหาlike
Date :
2009-08-26 11:03:42
By :
uw6e5o
Load balance : Server 01