|
 |
|
ขอตัวอย่างโค้ด ในการกำหนด ราคาตั้งราคาสินค้าไม่เท่ากัน จะขึ้นอยู่กับเงื่อนไขจำนวนของการสั่งซื้อ |
|
 |
|
|
 |
 |
|
Code (JavaScript)
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>ThaiCreate.Com Tutorial</title>
<script language = "JavaScript">
//**** List Model (Start) ***//
function ListModel(SelectValue)
{
frmMain.ddlModel.length = 0
frmMain.ddlYear.length = 0
//*** Insert null Default Value ***//
var myOption = new Option('','')
frmMain.ddlModel.options[frmMain.ddlModel.length]= myOption
x = "1"
mySubList = new Array();
strGroup = "TOYOTA";
strValue = "VIOS";
strItem = "Vios";
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])
frmMain.ddlModel.options[frmMain.ddlModel.length]= myOption
}
x = "2"
mySubList = new Array();
strGroup = "TOYOTA";
strValue = "ALTIS";
strItem = "Altis";
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])
frmMain.ddlModel.options[frmMain.ddlModel.length]= myOption
}
x = "3"
mySubList = new Array();
strGroup = "HONDA";
strValue = "CIVIC";
strItem = "Civic";
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])
frmMain.ddlModel.options[frmMain.ddlModel.length]= myOption
}
x = "4"
mySubList = new Array();
strGroup = "HONDA";
strValue = "CITY";
strItem = "City";
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])
frmMain.ddlModel.options[frmMain.ddlModel.length]= myOption
}
}
//**** List Model (End) ***//
//**** List Year (Start) ***//
function ListYear(SelectValue)
{
frmMain.ddlYear.length = 0
//*** Insert null Default Value ***//
var myOption = new Option('','')
frmMain.ddlYear.options[frmMain.ddlYear.length]= myOption
x = "1";
mySubList = new Array();
strGroup = "VIOS";
strValue = "2003";
strItem = "2003";
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])
frmMain.ddlYear.options[frmMain.ddlYear.length]= myOption
}
x = "2";
mySubList = new Array();
strGroup = "VIOS";
strValue = "2006";
strItem = "2006";
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])
frmMain.ddlYear.options[frmMain.ddlYear.length]= myOption
}
x = "3";
mySubList = new Array();
strGroup = "VIOS";
strValue = "2007";
strItem = "2007";
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])
frmMain.ddlYear.options[frmMain.ddlYear.length]= myOption
}
x = "4";
mySubList = new Array();
strGroup = "ALTIS";
strValue = "2002";
strItem = "2002";
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])
frmMain.ddlYear.options[frmMain.ddlYear.length]= myOption
}
x = "5";
mySubList = new Array();
strGroup = "ALTIS";
strValue = "2004";
strItem = "2004";
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])
frmMain.ddlYear.options[frmMain.ddlYear.length]= myOption
}
x = "6";
mySubList = new Array();
strGroup = "ALTIS";
strValue = "2009";
strItem = "2009";
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])
frmMain.ddlYear.options[frmMain.ddlYear.length]= myOption
}
x = "7";
mySubList = new Array();
strGroup = "CIVIC";
strValue = "2001";
strItem = "2001";
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])
frmMain.ddlYear.options[frmMain.ddlYear.length]= myOption
}
x = "8";
mySubList = new Array();
strGroup = "CIVIC";
strValue = "2003";
strItem = "2003";
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])
frmMain.ddlYear.options[frmMain.ddlYear.length]= myOption
}
x = "9";
mySubList = new Array();
strGroup = "CIVIC";
strValue = "2011";
strItem = "2011";
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])
frmMain.ddlYear.options[frmMain.ddlYear.length]= myOption
}
x = "10";
mySubList = new Array();
strGroup = "CITY";
strValue = "2000";
strItem = "2000";
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])
frmMain.ddlYear.options[frmMain.ddlYear.length]= myOption
}
x = "11";
mySubList = new Array();
strGroup = "CITY";
strValue = "2005";
strItem = "2005";
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])
frmMain.ddlYear.options[frmMain.ddlYear.length]= myOption
}
x = "12";
mySubList = new Array();
strGroup = "CITY";
strValue = "2009";
strItem = "2009";
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])
frmMain.ddlYear.options[frmMain.ddlYear.length]= myOption
}
}
//**** List Year (End) ***//
</script>
</head>
<form name="frmMain" action="" method="post">
Brand
<select id="ddlGeo" name="ddlGeo" onChange = "ListModel(this.value)">
<option selected value=""></option>
<option value="TOYOTA">TOYOTA</option>
<option value="HONDA">HONDA</option>
</select>
Model
<select id="ddlModel" name="ddlModel" style="width:100px" onChange = "ListYear(this.value)"></select>
Year
<select id="ddlYear" name="ddlYear" style="width:100px"></select>
</form>
</body>
</html>
|
 |
 |
 |
 |
Date :
2011-06-15 21:41:15 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณนะคร๊าาา....จะลองนำไปประยุกต์ดูค่ะ
|
 |
 |
 |
 |
Date :
2011-06-16 09:36:46 |
By :
chadjan |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 05
|