|
俺先说说的俺的意图与实现思路吧:页面上有四个radio按钮,每个按钮对应表格里各个GIF文件,这四个GIF文件相当于四样产品,俺想客户每选定一个 radio ,就激活一段PHP代码,这段PHP代码就实现连接MYSQL数据库,并取得对应某个产品的条形码与密码的值,然后通过一段 javascript代码作判断,跟着将条形码的值显示在条形码框里,跟着就在密码框里输入六位数字,然后按确定,作个判断,如果输入数字跟取得的产品密码值相同的,就弹出该产品的下载对话框,如果不一样就弹出密码不正确的警告框。代码如下:
downtest.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> 下载测试页 </TITLE>
<META NAME="Generator" CONTENT="editplus&vi&emacs&phped">
<META NAME="Author" CONTENT="evan">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>
<BODY>
<p align="center" > <b>
<font color="0000FF" face ="黑体“ size="18" >
下载测试页
</font>
</b>
</p>
<hr>
<br>
<br>
<script language="javascript">
<!--begin
var wares="";
//radio buttons are either/or elements
//MIE evaluates onClick of an elemet,NN does not
function getRadio(what) {
//get the wares
j=what.wares.length;//alert(j)
for (i=0;i<j;i++) {
if (what.wares.checked) var wares = what.wares.value
//show selections
what.barcode.value= (wares)
}
//end==>
}
</script>
<?php
// this php script be use to vote in
// barcode and passwd from epay_all
// datatable of epay database .
$dbcnt= mysql_pconnect("localhost","root","")or die("Could not connect");
$reselt= mysql_select_db("epay") or die("Could not connect");
$sqla= "select barcode,passwd from epay_all where ware = '高山' limit 1" ;
$sqlb= "select barcode,passwd from epay_all where ware = '大海' limit 1" ;
$sqlc= "select barcode,passwd from epay_all where ware = '蓝天' limit 1" ;
$sqld= "select barcode,passwd from epay_all where ware = '白云' limit 1" ;
if radioa=cheched {
$resulta=mysql_query($sqla)or die ("Could not connect");
$row=mysql_fetch_array($resulta);
$barcode=$row["barcode"];
$passwd=$row["passwd"];
}
else if radiob=cheched{
$resultb=mysql_query($sqlb) or die ("Could not connect");
$row=mysql_fetch_array($resultb);
$barcode=$row["barcode"];
$passwd=$row["passwd"];
}
else if radioc=cheched {
$resultc=mysql_query($sqlc) or die("Could not connect");
$row=mysql_fetch_array($resultc);
$barcode=$row["barcode"];
$passwd=$row["passwd"];
}
else if radiod=cheched {
$resultd=mysql_query($sqld) or die("Could not connect");
$row=mysql_fectch_array($resultd);
$barcode=$row["barcode"];
$passwd=$row["passwd"];
}
# mysql_close($dbcnt);
?>
<script language="javascript">
<!--begin
//compare passwd and $passwd two variable,
//if passwd equal $passwd ,point to a href,
//else ponit to alert dialog box.
function compare(){
var $passwd;
if ("passwd" == $passwd){
location.href="image/001.gif";
}
else {
alert("密码不正确,请正确输入密码!");
}
}
//end==>
</script>
<p align="center">
<table border="1" width="50%">
<tr>
<td width="25%"> <img src="image/001.gif" width="30" height="30"></td>
<td width="25%"> <img src="image/002.gif" width="30" height="30"></td>
<td width="25%"> <img src="image/003.gif" width="30" height="30"></td>
<td width="25%"> <img src="image/004.gif" width="30" height="30"></td>
</tr>
</table>
</p>
<p>
<form name="picform">
<div onClick='getRadio(document.picform)' />
<p align="center">
<input type="radio" name="wares" value="20181593578" id="radioa" >高山   <input type="radio" name="wares" value="20181472589" id="radiob">大海   <input type="radio" name="wares" value="$barcode" id="radioc">蓝天   <input type="radio" name="wares" value="$barcode" id="radiod">白云   
</p>
<br><br>
</div>
<p align="center">
产生条形码:<input type="text" name="barcode" size="24" maxlength="24">
</p>
<p align="center">
输入  密码: <input type="text" name="passwd" id="passwd" value="" size ="24" maxlength="24"></p>
<p align="center">
<input type="button" name="button" value="确认" size="8" onclick="compare()">    <input type="reset" name="reset" value="重置" size="8" >
</p>
</form>
</p>
<hr>
<marquee> 将相本无种,男儿当自强!</marquee>
</BODY>
</HTML> |
|