|
|
|
ดึงข้อมูลจากฐานข้อมูล YES กับ NO ต้องทํายังไง เพื่อให้ enable & disable form |
|
|
|
|
|
|
|
ใช้จาวาสคริปท์ครับ
|
|
|
|
|
Date :
2011-12-27 09:48:05 |
By :
Dragons_first |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
คือว่า code ของ The Gunner รับค่าจาก textbox ครับผม แต่ว่าตอนนี้ อยากให้รับค่าจาก ฐานข้อมูลครับ ไม่รู้จะไปเปี่ยนตรงไหน ครับข่วยหน่อยครับ
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<center>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874" />
<title>Untitled Document</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" ></script>
<script type="text/javascript">
function chk_form(i){
var value = $('#chk_val').val();
var t = '<font color="red">Disabled</font>';
var f = '<font color="green">Enable</font>';
if(value.length>0){
if(value=='NO'){
$('#user').attr('disabled','');
$('#pass').attr('disabled','');
$('#phone').attr('disabled','');
$('#address').attr('disabled','');
$('#1').attr('disabled','');
$('#2').attr('disabled','');
$('#3').attr('disabled','');
$('#4').attr('disabled','');
$('#5').attr('disabled','');
$('#6').attr('disabled','');
$('#7').attr('disabled','');
$('#8').attr('disabled','');
$('#9').attr('disabled','');
$('#10').attr('disabled','');
$('#11').attr('disabled','');
$('#12').attr('disabled','');
$('#result').html(t);
}else if(value=='YES'){
$('#user').removeAttr("disabled");
$('#pass').removeAttr("disabled");
$('#phone').removeAttr("disabled");
$('#address').removeAttr("disabled");
$('#1').removeAttr("disabled");
$('#2').removeAttr("disabled");
$('#3').removeAttr("disabled");
$('#4').removeAttr("disabled");
$('#5').removeAttr("disabled");
$('#6').removeAttr("disabled");
$('#7').removeAttr("disabled");
$('#8').removeAttr("disabled");
$('#9').removeAttr("disabled");
$('#10').removeAttr("disabled");
$('#11').removeAttr("disabled");
$('#12').removeAttr("disabled");
$('#result').html(f);
}
}
}
</script>
</head>
<body>
<div id="vdo_id">
<form id="form1">
<table border="0">
<tr>
<td>Username:</td>
<td><input type="text" id="user"></td>
</tr>
<tr>
<td>Password:</td>
<td><input type="text" id="pass"></td>
</tr>
<td>phone:</td>
<td><input type="text" id="phone"></td>
</tr>
<td>address:</td>
<td><input type="text" id="address"></td>
</tr>
<tr>
<td><div id="result"></div></td>
<td><input type="text" id="chk_val" onchange="chk_form(this.id)"></td>
</tr>
</table>
</form>
</div>
</body>
</html>
</center>
<BODY>
<script language="javascript">
function fncSubmit()
{
if(document.formregister.username.value == "")
{
alert('Please input User Name');
document.formregister.username.focus();
return false;
}
if(document.formregister.password.value == "")
{
alert('Please input Password');
document.formregister.password.focus();
return false;
}
if(document.formregister.Namesurname.value == "")
{
alert('Please input Name and Surname');
document.formregister.Namesurname.focus();
return false;
}
if ((document.formregister.email.value.length < 9) || (document.formregister.email.value.indexOf('@') == -1) || (document.formregister.email.value.indexOf('.') == -1))
{
alert("Please enter a valid email address like [email protected]");
document.formregister.email.focus();
return false;
}
if(document.formregister.age.value == "")
{
alert('Please input age');
document.formregister.age.focus();
return false;
}
if(document.formregister.address.value == "")
{
alert('Please input Address');
document.formregister.address.focus();
return false;
}
document.formregister.submit();
}
</script>
<br/>
<br/>
<center>
<div id="12" >
<form action="Printregister.php" method="post" name="formregister" onSubmit="JavaScript:return fncSubmit();">
<table width="446" border="0">
<tr>
<td width="159"><span class="style4"><div align="right">Name:</div></span></td>
<td width="227"><label>
<div align="left"><input name="username" id="1" type="text"></div>
</label></td>
</tr>
<tr>
<td><span class="style4"><div align="right">Password:</div></span></td>
<td><label>
<div align="left"><input type="password" name="password" id="2" /></div>
</label></td>
</tr>
<tr>
<td><span class="style4"><div align="right">Name and Surname:</div></span></td>
<td><label>
<div align="left"> <input type="text" name="Namesurname" id="3" /></div>
</label></td>
</tr>
<tr>
<td><span class="style4"><div align="right">Gender:</div></span></td>
<td><div align="left"><label>
<input type="radio" name="gender" id="4" value="male" />
</label>
<label>
<span class="style4">Male
<input type="radio" name="gender" id="5" value="female" />
Female</span></label></div></td>
</tr>
<tr>
<td><span class="style4"><div align="right">Date of Birth:</div></span></td>
<td><div align="left"><SELECT class=panelA8 name=Arrival_day>
<OPTION value="Date" id="11" selected>Date</OPTION>
<OPTION value=1>1</OPTION> <OPTION value=2>2</OPTION>
<OPTION value=3>3</OPTION> <OPTION value=4>4</OPTION>
<OPTION value=5>5</OPTION> <OPTION value=6>6</OPTION>
<OPTION value=7>7</OPTION> <OPTION value=8>8</OPTION>
<OPTION value=9>9</OPTION> <OPTION value=10>10</OPTION>
<OPTION value=11>11</OPTION> <OPTION value=12>12</OPTION>
<OPTION value=13>13</OPTION> <OPTION value=14>14</OPTION>
<OPTION value=15>15</OPTION> <OPTION value=16>16</OPTION>
<OPTION value=17>17</OPTION> <OPTION value=18>18</OPTION>
<OPTION value=19>19</OPTION> <OPTION value=20>20</OPTION>
<OPTION value=21>21</OPTION> <OPTION value=22>22</OPTION>
<OPTION value=23>23</OPTION> <OPTION value=24>24</OPTION>
<OPTION value=25>25</OPTION> <OPTION value=26>26</OPTION>
<OPTION value=27>27</OPTION> <OPTION value=28>28</OPTION>
<OPTION value=29>29</OPTION> <OPTION value=30>30</OPTION>
<OPTION value=31>31</OPTION></SELECT>
<SELECT class=panelA8 size=1 name=Arrival_month>
<OPTION value="Month" selected>Month</OPTION>
<OPTION value=1>Jan.</OPTION><OPTION value=2>Feb.</OPTION>
<OPTION value=3>Mar.</OPTION> <OPTION value=4>Apr.</OPTION>
<OPTION value=5>May</OPTION> <OPTION value=6>Jun.</OPTION>
<OPTION value=7>Jul.</OPTION> <OPTION value=8>Aug.</OPTION>
<OPTION value=9>Sep.</OPTION> <OPTION value=10>Oct.</OPTION>
<OPTION value=11>Nov.</OPTION> <OPTION value=12>Dec.</OPTION></SELECT>
<SELECT class=panelA8 size=1 name=Arrival_year>
<OPTION value="Year" selected>Year</OPTION>
<OPTION value=1940>1940</OPTION><OPTION value=1941>1941</OPTION>
<OPTION value=1942>1942</OPTION><OPTION value=1943>1943</OPTION>
<OPTION value=1941>1944</OPTION><OPTION value=1941>1945</OPTION>
<OPTION value=1941>1946</OPTION><OPTION value=1941>1947</OPTION>
<OPTION value=1941>1948</OPTION><OPTION value=1941>1949</OPTION>
<OPTION value=1941>1950</OPTION><OPTION value=1941>1951</OPTION>
<OPTION value=1941>1952</OPTION><OPTION value=1941>1953</OPTION>
<OPTION value=1941>1954</OPTION><OPTION value=1941>1955</OPTION>
<OPTION value=1941>1956</OPTION><OPTION value=1941>1957</OPTION>
<OPTION value=1941>1958</OPTION><OPTION value=1941>1959</OPTION>
<OPTION value=1941>1960</OPTION><OPTION value=1941>1961</OPTION>
<OPTION value=1941>1962</OPTION><OPTION value=1941>1963</OPTION>
<OPTION value=1941>1964</OPTION><OPTION value=1941>1965</OPTION>
<OPTION value=1941>1966</OPTION><OPTION value=1941>1967</OPTION>
<OPTION value=1941>1968</OPTION><OPTION value=1941>1969</OPTION>
<OPTION value=1941>1970</OPTION><OPTION value=1941>1971</OPTION>
<OPTION value=1941>1972</OPTION><OPTION value=1941>1973</OPTION>
<OPTION value=1941>1974</OPTION><OPTION value=1941>1975</OPTION>
<OPTION value=1941>1976</OPTION><OPTION value=1941>1977</OPTION>
<OPTION value=1941>1978</OPTION><OPTION value=1941>1979</OPTION>
<OPTION value=1941>1980</OPTION><OPTION value=1941>1981</OPTION>
<OPTION value=1941>1982</OPTION><OPTION value=1941>1983</OPTION>
<OPTION value=1941>1984</OPTION><OPTION value=1941>1985</OPTION>
<OPTION value=1941>1986</OPTION><OPTION value=1941>1987</OPTION>
<OPTION value=1941>1988</OPTION><OPTION value=1941>1989</OPTION>
<OPTION value=1941>1990</OPTION><OPTION value=1941>1991</OPTION>
<OPTION value=1941>1992</OPTION><OPTION value=1941>1993</OPTION>
<OPTION value=1941>1994</OPTION><OPTION value=1941>1995</OPTION>
<OPTION value=1941>1996</OPTION><OPTION value=1941>1997</OPTION>
<OPTION value=1941>1998</OPTION><OPTION value=1941>1999</OPTION>
<OPTION value=1941>2000</OPTION><OPTION value=1941>2001</OPTION>
<OPTION value=1941>2002</OPTION><OPTION value=1941>2003</OPTION>
<OPTION value=1941>2004</OPTION><OPTION value=1941>2005</OPTION>
<OPTION value=1941>2006</OPTION><OPTION value=1941>2007</OPTION>
<OPTION value=1941>2008</OPTION><OPTION value=1941>2009</OPTION>
<OPTION value=1941>2010</OPTION><OPTION value=1941>2011</OPTION>
</SELECT></div></td>
</tr>
<tr>
<td><span class="style4"><div align="right">Age:</div></span></td>
<td><label>
<div align="left"> <input type="text" name="age" id="6" /></div>
</label></td>
</tr>
<tr>
<td><span class="style4"><div align="right">Address:</div></span></td>
<td><label>
<div align="left"><textarea name="address" id="7" cols="35" rows="3"></textarea></div>
</label></td>
</tr>
<tr>
<td><span class="style4"><div align="right">E-mail:</div></span></td>
<td><label>
<div align="left"><input type="text" name="email" id="8" /></div>
</label></td>
</tr>
<tr>
<td colspan="2"> <div align="center"><label>
<input name="Submit" type="submit" class="style4" id="9" value="Submit" />
</label>
<label>
<input name="Reset" type="reset" class="style4" id="10" value="Reset" />
</label></div></td>
</tr>
</table>
</form>
</div>
</center>
|
|
|
|
|
Date :
2011-12-27 13:13:54 |
By :
poulim |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|