<?php
/*** By Weerachai Nukitram ***/
/*** http://www.ThaiCreate.Com ***/
$objConnect = mysql_connect("localhost","root","200298") or die("Error Connect to Database");
$objDB = mysql_select_db("form");
@mysql_query("SET NAMES UTF8");
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>ThaiCreate.Com Tutorial</title>
<script language = "JavaScript">
//**** List Province (Start) ***//
function ListProvince(SelectValue)
{
form1.ddlProvince.length = 0
//form1.ddlAmphur.length = 0
//*** Insert null Default Value ***//
var myOption = new Option('','')
form1.ddlProvince.options[form1.ddlProvince.length]= myOption
<?
$intRows = 0;
$strSQL = "SELECT * FROM type2 ORDER BY type_id ASC ";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$intRows = 0;
while($objResult = mysql_fetch_array($objQuery))
{
$intRows++;
?>
x = <?=$intRows;?>;
mySubList = new Array();
strGroup = <?=$objResult["type1"];?>;
strValue = "<?=$objResult["type_id"];?>";
strItem = "<?=$objResult["type_name"];?>";
mySubList[x,0] = strItem;
mySubList[x,1] = strGroup;
mySubList[x,2] = strValue;
if (mySubList[x,1] == SelectValue){
var myOption = new Option(mySubList[x,0], mySubList[x,2])
form1.ddlProvince.options[form1.ddlProvince.length]= myOption
}
<?
}
?>
}
//**** List Province (End) ***//
</script>
<script type="text/javascript" src="./js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="./js/common.js"></script>
</head>
<body>
<form name="form1" method="post" action="uploadjq2.php" enctype="multipart/form-data">
<div class='input file' id="line[]">
<input type="file" name="filUpload[]" id="file_upload">
<input name="namelink[]" type="text">
<a href='#' class='add_another_file_input hide'>
<img src='plus.jpg' alt='Add Icon' width="20" height="20" />
</a>DOC TYPE
<select id="ddlGeo[]" name="ddlGeo[]" onChange = "ListProvince(this.value)">
<option selected value=""></option>
<?
$strSQL = "SELECT * FROM type1 ORDER BY type_id ASC ";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
while($objResult = mysql_fetch_array($objQuery))
{
?>
<option value="<?=$objResult["type_id"];?>">
<?=$objResult["type_name"];?>
</option>
<?
}
?>
</select>
<select id="ddlProvince" name="ddlProvince" style="width:120px" onChange = "">
</select>
</div>
<input name="btnSubmit" type="submit" value="Submit">
</form>
</body>
</html>
อันนี้เป็น common.js Code (JavaScript)
$(document).ready(function(){
$x=0;
$('.add_another_file_input').show();
// add click handler to add icon
$('.add_another_file_input').click(function(){
// get input html
var html = $(this).parents('.input').html();
// add to form
$('.file:last').after( '<div class="input file hide">'+html+'</div>' );
// hide the add icon
$('.file:last a.add_another_file_input').hide();
// fade in the input
$('.file:last').fadeIn().removeClass('hide');
return false;
});
});