我有测试页面:
<!DOCTYPE html>
<html>
<head>
<title>Loading from DB</title>
<link rel="stylesheet" href="codebase/webix.css" type="text/css">
<script src="codebase/webix.js" type="text/javascript"></script>
<style>
.submitButton {
-moz-box-shadow: 11px 10px 14px -7px #276873;
-webkit-box-shadow: 11px 10px 14px -7px #276873;
box-shadow: 11px 10px 14px -7px #276873;
background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #599bb3), color-stop(1, #408c99));
background:-moz-linear-gradient(top, #599bb3 5%, #408c99 100%);
background:-webkit-linear-gradient(top, #599bb3 5%, #408c99 100%);
background:-o-linear-gradient(top, #599bb3 5%, #408c99 100%);
background:-ms-linear-gradient(top, #599bb3 5%, #408c99 100%);
background:linear-gradient(to bottom, #599bb3 5%, #408c99 100%);
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#599bb3', endColorstr='#408c99',GradientType=0);
background-color:#599bb3;
-moz-border-radius:8px;
-webkit-border-radius:8px;
border-radius:8px;
display:inline-block;
cursor:pointer;
color:#ffffff;
font-family:Arial;
font-size:10px;
font-weight:bold;
padding:6px 16px;
text-decoration:none;
text-shadow:0px 1px 0px #3d768a;
}
.submitButton:hover {
background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #408c99), color-stop(1, #599bb3));
background:-moz-linear-gradient(top, #408c99 5%, #599bb3 100%);
background:-webkit-linear-gradient(top, #408c99 5%, #599bb3 100%);
background:-o-linear-gradient(top, #408c99 5%, #599bb3 100%);
background:-ms-linear-gradient(top, #408c99 5%, #599bb3 100%);
background:linear-gradient(to bottom, #408c99 5%, #599bb3 100%);
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#408c99', endColorstr='#599bb3',GradientType=0);
background-color:#408c99;
}
.submitButton:active {
position:relative;
top:1px;
}
</style>
</head>
<body background="images/background_mono1.jpg">
<img src="images/azerconnect_logo.jpg" width="200" height="116" alt=""/>
<?php
//$filename = getcwd() . "/test.txt";
//echo $filename;
//$line_i_am_looking_for = 5;
//$lines = file( $filename , FILE_IGNORE_NEW_LINES );
//$lines[$line_i_am_looking_for] = '6my modified line';
//file_put_contents( $filename , implode( "\n", $lines ) );
require_once('functions.php');
?>
<form action="submit.php" method="post">
<textarea placeholder="WO number (separate with comma if several)" rows="4" cols="30" name="WO_textarea" ></textarea>
<input type="submit" class="submitButton" value="Submit">
</form>
<hr>
<div class='header_comment'>Test WO info</div>
<div id="testA" style='height:650px'></div>
<div id="testB" style='height:350px'></div>
<hr>
<script type="text/javascript" charset="utf-8">
webix.ready(function(){
grida = webix.ui({
container:"testA",
view:"datatable",
columns:[
{ id:"idWO", header:"Work Order ID", width:200 },
{ id:"WO_STATUS",header:"Work Order Status", width:120 }
// { id:"size", header:"Size" , width:80 },
// { id:"architecture", header:"PC", width:60 }
],
autowidth:true,
autoheight:true,
url: "data/data.php",
});
gridb = webix.ui({
container:"testB",
"view": "form",
"elements": [
{
"view": "textarea",
"name": "woNumber",
"id": "textarea",
"label": "",
"width": 300,
"height": 200,
"options": [
"onViewResize"
],
"value": "",
"placeholder": "WO number (separate with comma if several)",
"labelPosition": "top"
},
{
"view": "button",
"name": "getWODetails",
"label": "",
"value": "Submit",
"options": [
"autowidth:true"
],
on:{
onItemClick:function(id){
webix.message("Sikim BLEAT'!!!");
saveToFile();
/* onItemClick: getTextareaData;
*/
}
},
"labelPosition": "top"
},
{
"view": "button",
"id": "button1",
"name": "getWODetails",
"label": "",
"value": "Passss",
"options": [
"autowidth:true"
],
on:{
onItemClick:function(){
webix.message("Values of textarea is "+$$('textarea').getValue());
webix.ajax().post("submit.php");
}
},
"labelPosition": "top"
}
]
});
});
</script>
<form method="post" action="submit.php">
<input type="submit" name="f_1">
</form>
<input type="checkbox" name="marks" id="marks" />
<input type="text" name="studentMarks" id="studentMarks">
</body>
</html>
这是我的 submit.php :
<?php
//include 'scriptss2.php';
require_once('functions.php');
saveToFileWithVar();
echo "It works";
header( 'Location: index.php');
?>
这是我的function.php:
<?php
function saveToFileWithVar()
{
if ($_POST['WO_textarea'] != ''){
echo $_POST['WO_textarea']; //textarea! е \n \r
echo nl2br($_POST['WO_textarea']); //textarea! html с сохранением пробелов и переносов строк
}else die('Please enter WO number(s)!');
$filename = getcwd() . "/data/data.php";
echo $filename;
$testVar = 'Huy6';
$line_i_am_looking_for = 16;
$lines = file( $filename , FILE_IGNORE_NEW_LINES );
//$lines[$line_i_am_looking_for] = ($_POST['WO_textarea']+'tettr');
$lines[$line_i_am_looking_for] = ('$data->render_sql("SELECT idWO, WO_STATUS FROM GENERIC_TABLES.WO WHERE idWO IN ('.$$('textarea').getValue().')", "", "idWO, WO_STATUS");');
//$lines[$line_i_am_looking_for] = ('$data->render_sql("SELECT idWO, WO_STATUS FROM GENERIC_TABLES.WO WHERE idWO IN ('.$_POST['WO_textarea'].')", "", "idWO, WO_STATUS");');
file_put_contents( $filename , implode( "\n", $lines ) );
echo $testVar;
echo ('$data->render_sql("SELECT idWO, WO_STATUS FROM GENERIC_TABLES.WO WHERE idWO IN ('.$_POST['WO_textarea'].')", "", "idWO, WO_STATUS");');
}
?>
所以,我想做什么 - 当我点击 Passss 按钮时,它会从textarea(我可以使用$$('textarea').getValue())
函数轻松完成)中获取文本。
我需要将此值添加到字符串下面:
$lines[$line_i_am_looking_for] = ('$data->render_sql("SELECT idWO, WO_STATUS FROM GENERIC_TABLES.WO WHERE idWO IN ('.$$('textarea').getValue().')", "", "idWO, WO_STATUS");');
现在我想把这个变量传递给function.php,但我无法做到。 我相信可能会有小错误,但我无法看到它。