01.
<script type=
"text/javascript"
>
02.
$(
function
(){
03.
$(
"#addRow"
).click(
function
(){
04.
var
NR =
""
;
05.
NR=
"<tr>"
;
06.
NR+=
"<td width=\"140\" valign=\"top\">"
;
07.
NR+=
"<input type=\"text\" name=\"date[]\" id=\"date[]\" class=\"datepic\"/>"
;
08.
09.
NR+=
"</td>"
;
10.
NR+=
"<td width=\"140\" valign=\"top\">"
;
11.
12.
NR+=
"<select name=\"account[]\" class=\"account[]\">"
;
13.
14.
NR+=
"<option selected=\"selected\">--เลือกบัญชี--</option>"
;
15.
NR+=
"</select>"
;
16.
NR+=
"</td>"
;
17.
NR+=
"<td width=\"140\">"
;
18.
NR+=
"<textarea name=\"detail[]\" id=\"detail[]\" cols=\"40\" rows=\"2\"></textarea>"
;
19.
20.
NR+=
"</td>"
;
21.
NR+=
"<td width=\"140\" valign=\"top\">"
;
22.
NR+=
"<input type=\"text\" name=\"price[]\" id=\"price[]\" />"
;
23.
24.
NR+=
"</td>"
;
25.
NR+=
"</tr>"
;
26.
27.
$(
"#myTbl"
).append($(NR));
28.
$(
'.datepic'
).calendarsPicker({ yearRange:
'c-5:c+0'
, calendar: $.calendars.instance(
'thai'
,
'th'
)});
29.
});
30.
$(
"#removeRow"
).click(
function
(){
31.
if
($(
"#myTbl tr"
).size()>2){
32.
$(
"#myTbl tr:last"
).remove();
33.
}
else
{
34.
alert(
"ต้องมีรายการข้อมูลอย่างน้อย 1 รายการ"
);
35.
}
36.
});
37.
});
38.
</script>
39.
40.
41.
<form id=
"form1"
name=
"form1"
method=
"post"
action=
"saveIncome.php"
>
42.
<table id=
"myTbl"
width=
"650"
border=
"1"
cellspacing=
"0"
cellpadding=
"0"
>
43.
<tr>
44.
<td width=
"140"
>วันที่</td>
45.
<td width=
"140"
>บัญชี</td>
46.
<td width=
"300"
>รายการ</td>
47.
<td width=
"200"
>จำนวนเงิน (บาท)</td>
48.
</tr>
49.
50.
<tr id=
"firstTr"
>
51.
<td width=
"140"
valign=
"top"
>
52.
53.
54.
<input type=
"text"
name=
"date[]"
class
=
"datepic"
id=
"date[]"
>
55.
</td>
56.
<td width=
"140"
valign=
"top"
>
57.
58.
<select name=
"account[]"
class
=
"account[]"
>
59.
60.
<option selected=
"selected"
>--เลือกบัญชี--</option>
61.
<?
$sql
=
"Select * From accountbank where cid='$com' AND bank ='$bank' "
;
62.
$result
=mysql_query(
$sql
);
63.
while
(
$rows
=mysql_fetch_array(
$result
)) {
64.
?>
65.
<option value=
"<? echo $rows['accid']; ?>"
><?
echo
$rows
[
'accname'
].
"("
.
$rows
[
'accno'
].
")"
; ?></option>
66.
<? } ?>
67.
</select>
68.
69.
</td>
70.
<td width=
"300"
><textarea name=
"detail[]"
id=
"detail[]"
cols=
"40"
rows=
"2"
></textarea></td>
71.
<td width=
"200"
valign=
"top"
><input type=
"text"
name=
"price[]"
id=
"price[]"
OnKeyPress=
"return chkNumber(this);"
/></td>
72.
</tr>
73.
</table>
74.
<br />
75.
<table width=
"500"
border=
"0"
cellspacing=
"0"
cellpadding=
"0"
>
76.
<tr>
77.
<td>
78.
<button id=
"addRow"
type=
"button"
>+</button>
79.
80.
<button id=
"removeRow"
type=
"button"
>-</button>
81.
82.
83.
84.
85.
<button id=
"Submit"
type=
"submit"
>เพิ่มรายรับ</button>
86.
<p> <a href=
"showIncome.php"
>ดูข้อมูลรายรับ</a></p>
87.
</td>
88.
</tr>
89.
</table>
90.
</form>