1
GET URL을 통해 날짜 매개 변수를 전달하는 데 문제가 있습니다. datepicker가 연결된 두 입력 필드에서 데이터를 가져옵니다.datepicker로 날짜를 얻고 GET으로 전달하는 방법?
$(".options input[type='submit']").click(function() {
$('#From').datepicker();
$('#To').datepicker();
var $From = $('#From').datepicker('getDate').getDate();
var $To = $('#To').datepicker('getDate').getDate();
$('#placeholder').html('<img src="php/jpgraph/example2.php?From=' + $From + '&To=' + $To + '" />');
});
HTML 페이지 : 여기 코드입니다
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="layout.css" type="text/css"/>
<link rel="stylesheet" href="jquery-ui-1.8.17.custom.css" type="text/css" />
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery-ui.js"></script>
<script type="text/javascript" src="newjavascript.js"></script>
</head>
<body>
<div id="container">
<div id="sidemenu">
<div class="options">
Датум од:<input type="text" id="From" name="From" size="10"/><br />
Датум до:<input type="text" id="To" name="To" size="10"/>
</div>
<br />
<div class="options">
<input type="submit" value="Show">
</div>
</div>
<div id="content">
<div id="placeholder" style="width:600px;height:300px;"></div>
</div>
</div><!-- divContainer -->
</body>
</html>
내가 날짜 선택기 이미지 쇼에서 날짜를 선택
. 하지만 datepicker로 날짜를 선택하지 않으면 아무 것도 표시되지 않습니다. 어쩌면 날짜가 선택되지 않았는지 검사 한 다음 값을 빈 문자열로 설정할 수 있습니다. 다음과 같이 입력하십시오 :if ($From == null) {
$From = '';
}
if ($To == null) {
$To = '';
}
시도했지만 작동하지 않습니다. 문제의 해결책은 무엇일까요?
편집 : 지금은, 내가 문제를 단순화하기 위해, 서버 측에서 PARAMS을 GET 처리하지만, 살펴하지 않습니다
<?php
require_once ('jpgraph.php');
require_once ('jpgraph_line.php');
$con = mysql_connect("localhost", "user", "pass");
if (!$con) {
die('Could not connect:' . mysql_error());
}
mysql_select_db("db", $con);
$result = mysql_query("select Temperature from TEMPERATURE");
$niz = array();
while ($row = mysql_fetch_array($result)) {
$niz[] = $row['Temperature'];
}
$graph = new Graph(600,400);
$graph->SetScale('intint');
$graph->title->set('Title');
$graph->xaxis->title->Set('Day');
$graph->yaxis->title->Set('Temp');
$lineplot=new LinePlot($niz);
$lineplot->SetColor('blue');
$graph->Add($lineplot);
$graph->Stroke();
?>
이미지를 생성하는 코드가 필요합니다. – mauris
아마도'example2.php'에서 빈 값을 처리하지 않을 것입니다 –
PHP 코드 섹션도 추가하십시오. –