php源码:
function goto_price($type){
global $dbhost,$dbuser,$dbpasswd,$dbname,$price_genre_table,$price_class_table;
?><SCRIPT language=javascript >
var refresh_now=0;
var bigkinds=new Array(0);
var bigvalue=new Array(0);
var kinds=new Array(0);
var values=new Array(0);
var left=0;
var big=0;
var small=0;function init() {
initarrays();
initselects();
}
function initselects() {
document.f1.pc_genre.options.length=0;
for (var i=0;i<bigkinds.length;i++) {
document.f1.pc_genre.options.length++;
document.f1.pc_genre.options[i].text=bigkinds[i];
document.f1.pc_genre.options[i].value=bigvalue[i];
}}function initarrays() {<?
mysql_pconnect($dbhost,$dbuser,$dbpasswd);
$text="select * from $price_genre_table";
//$class_result = mysql_db_query($dbname, $class_sql);
mysql_select_db($dbname);
$rs = mysql_query($text);
$i=0;
while($rowt=mysql_fetch_array($rs))
{ $i++;
echo "addbig(\"".$rowt['genre']."\",".$rowt['id'].");\n"; $genreid=$rowt['id'];
$strsql="select * from $price_class_table where genreid=$genreid";
mysql_select_db($dbname);
$classrs = mysql_query($strsql); while($classrow=mysql_fetch_array($classrs))
{
echo "addsmall(".$i.",\"".$classrow["class"]."\",".$classrow['id'].");\n";
if($classrow['id']==$type)
{
$small=$classrow['id'];
$big=$rowt['id'];
}
}
}
?>
}function findindex(seltemp,newvalue) {
for (var i=0;i<seltemp.length;i++)
if (seltemp.options[i].value==newvalue) break;
return i;
}function changebig(newvalue) {
document.f1.pc_genre.selectedIndex=findindex(document.f1.pc_genre,newvalue);
big=newvalue;
updateclassid(document.f1.pc_genre.selectedIndex);}
function changesmall(newvalue) {
document.f1.type.selectedIndex=findindex(document.f1.type,newvalue);
small=newvalue;}
function updateclassid(n) {
document.f1.type.options.length=0;
for (var i=0;i<kinds[n].length;i++) {
document.f1.type.options.length++;
document.f1.type.options[i].text=kinds[n][i];
document.f1.type.options[i].value=values[n][i];
}
document.f1.type.selectedIndex=0;
}
//disptext为大类
//newvalue为序号
function addbig(disptext,newvalue) {
bigkinds.length++;
bigkinds[bigkinds.length-1]=disptext;
bigvalue.length++;
bigvalue[bigvalue.length-1]=newvalue;
kinds.length++;
kinds[kinds.length-1]=new Array(0);
values.length++;
values[values.length-1]=new Array(0);}
function addsmall(n,disptext,newvalue) {
kinds[n-1].length++;
kinds[n-1][kinds[n-1].length-1]=disptext;
values[n-1].length++;
values[n-1][values[n-1].length-1]=newvalue;
}</SCRIPT>
<SELECT
onchange=changebig(this.options[this.selectedIndex].value) name=pc_genre>
</SELECT>
<SELECT
onchange=changesmall(this.options[this.selectedIndex].value) name=type> </SELECT><SCRIPT language=javascript>
init();
<?
if(!isset($big)) $big=1;
if(!isset($small)) $small=1;?>
changebig(<?echo $big;?>);
changesmall(<?echo $small;?>);
</SCRIPT>
<?
}
生成网页的代码
<SCRIPT language=javascript >
var refresh_now=0;
var bigkinds=new Array(0);
var bigvalue=new Array(0);
var kinds=new Array(0);
var values=new Array(0);
var left=0;
var big=0;
var small=0;function init() {
initarrays();
initselects();
}
function initselects() {
document.f1.pc_genre.options.length=0;
for (var i=0;i<bigkinds.length;i++) {
document.f1.pc_genre.options.length++;
document.f1.pc_genre.options[i].text=bigkinds[i];
document.f1.pc_genre.options[i].value=bigvalue[i];
}}function initarrays() {addbig("品牌计算机",1);
addsmall(1,"方正商用机",17);
addsmall(1,"金长城服务器",16);
addsmall(1,"金长城家用机",15);
addsmall(1,"金长城商用机",14);
addsmall(1,"方正家用机",18);
addsmall(1,"方正服务器",19);
addsmall(1,"联想商用机",20);
addsmall(1,"联想家用机",21);
addsmall(1,"联想服务器",22);
addbig("笔记本",2);
addbig("电脑配件",3);
addsmall(3,"软驱",31);
addsmall(3,"光驱",30);
addsmall(3,"声卡",29);
addsmall(3,"显示卡",28);
addsmall(3,"机箱",32);
addsmall(3,"硬盘",27);
addsmall(3,"内存",26);
addsmall(3,"CPU",25);
addsmall(3,"主板",24);
addsmall(3,"键盘",33);
addsmall(3,"鼠标",34);
addsmall(3,"电源",49);
addbig("消耗品",4);
addbig("办公用品",5);
addsmall(5,"传真机",35);
addsmall(5,"打印机",36);
addbig("网络产品",6);
addsmall(6,"网卡",37);
addsmall(6,"集线器",38);
addsmall(6,"交换机",39);
addsmall(6,"ADSL",40);
addsmall(6,"路由器",41);
addsmall(6,"MODEM",48);
addbig("外设",7);
addsmall(7,"CTR显示器",43);
addsmall(7,"液晶显示器",44);
addsmall(7,"针式打印机",45);
addsmall(7,"喷墨打印机",46);
addsmall(7,"激光打印机",47);
}function findindex(seltemp,newvalue) {
for (var i=0;i<seltemp.length;i++)
if (seltemp.options[i].value==newvalue) break;
return i;
}function changebig(newvalue) {
document.f1.pc_genre.selectedIndex=findindex(document.f1.pc_genre,newvalue);
big=newvalue;
updateclassid(document.f1.pc_genre.selectedIndex);}
function changesmall(newvalue) {
document.f1.type.selectedIndex=findindex(document.f1.type,newvalue);
small=newvalue;}
function updateclassid(n) {
document.f1.type.options.length=0;
for (var i=0;i<kinds[n].length;i++) {
document.f1.type.options.length++;
document.f1.type.options[i].text=kinds[n][i];
document.f1.type.options[i].value=values[n][i];
}
document.f1.type.selectedIndex=0;
}function addbig(disptext,newvalue) {
bigkinds.length++;
bigkinds[bigkinds.length-1]=disptext;
bigvalue.length++;
bigvalue[bigvalue.length-1]=newvalue;
kinds.length++;
kinds[kinds.length-1]=new Array(0);
values.length++;
values[values.length-1]=new Array(0);}
function addsmall(n,disptext,newvalue) {
kinds[n-1].length++;
kinds[n-1][kinds[n-1].length-1]=disptext;
values[n-1].length++;
values[n-1][values[n-1].length-1]=newvalue;
}</SCRIPT>
<SELECT
onchange=changebig(this.options[this.selectedIndex].value) name=pc_genre>
</SELECT>
<SELECT
onchange=changesmall(this.options[this.selectedIndex].value) name=type> </SELECT><SCRIPT language=javascript>
init();
changebig(1);
changesmall(1);
</SCRIPT>
function goto_price($type){
global $dbhost,$dbuser,$dbpasswd,$dbname,$price_genre_table,$price_class_table;
?><SCRIPT language=javascript >
var refresh_now=0;
var bigkinds=new Array(0);
var bigvalue=new Array(0);
var kinds=new Array(0);
var values=new Array(0);
var left=0;
var big=0;
var small=0;function init() {
initarrays();
initselects();
}
function initselects() {
document.f1.pc_genre.options.length=0;
for (var i=0;i<bigkinds.length;i++) {
document.f1.pc_genre.options.length++;
document.f1.pc_genre.options[i].text=bigkinds[i];
document.f1.pc_genre.options[i].value=bigvalue[i];
}}function initarrays() {<?
mysql_pconnect($dbhost,$dbuser,$dbpasswd);
$text="select * from $price_genre_table";
//$class_result = mysql_db_query($dbname, $class_sql);
mysql_select_db($dbname);
$rs = mysql_query($text);
$i=0;
while($rowt=mysql_fetch_array($rs))
{ $i++;
echo "addbig(\"".$rowt['genre']."\",".$rowt['id'].");\n"; $genreid=$rowt['id'];
$strsql="select * from $price_class_table where genreid=$genreid";
mysql_select_db($dbname);
$classrs = mysql_query($strsql); while($classrow=mysql_fetch_array($classrs))
{
echo "addsmall(".$i.",\"".$classrow["class"]."\",".$classrow['id'].");\n";
if($classrow['id']==$type)
{
$small=$classrow['id'];
$big=$rowt['id'];
}
}
}
?>
}function findindex(seltemp,newvalue) {
for (var i=0;i<seltemp.length;i++)
if (seltemp.options[i].value==newvalue) break;
return i;
}function changebig(newvalue) {
document.f1.pc_genre.selectedIndex=findindex(document.f1.pc_genre,newvalue);
big=newvalue;
updateclassid(document.f1.pc_genre.selectedIndex);}
function changesmall(newvalue) {
document.f1.type.selectedIndex=findindex(document.f1.type,newvalue);
small=newvalue;}
function updateclassid(n) {
document.f1.type.options.length=0;
for (var i=0;i<kinds[n].length;i++) {
document.f1.type.options.length++;
document.f1.type.options[i].text=kinds[n][i];
document.f1.type.options[i].value=values[n][i];
}
document.f1.type.selectedIndex=0;
}
//disptext为大类
//newvalue为序号
function addbig(disptext,newvalue) {
bigkinds.length++;
bigkinds[bigkinds.length-1]=disptext;
bigvalue.length++;
bigvalue[bigvalue.length-1]=newvalue;
kinds.length++;
kinds[kinds.length-1]=new Array(0);
values.length++;
values[values.length-1]=new Array(0);}
function addsmall(n,disptext,newvalue) {
kinds[n-1].length++;
kinds[n-1][kinds[n-1].length-1]=disptext;
values[n-1].length++;
values[n-1][values[n-1].length-1]=newvalue;
}</SCRIPT>
<SELECT
onchange=changebig(this.options[this.selectedIndex].value) name=pc_genre>
</SELECT>
<SELECT
onchange=changesmall(this.options[this.selectedIndex].value) name=type> </SELECT><SCRIPT language=javascript>
init();
<?
if(!isset($big)) $big=1;
if(!isset($small)) $small=1;?>
changebig(<?echo $big;?>);
changesmall(<?echo $small;?>);
</SCRIPT>
<?
}
生成网页的代码
<SCRIPT language=javascript >
var refresh_now=0;
var bigkinds=new Array(0);
var bigvalue=new Array(0);
var kinds=new Array(0);
var values=new Array(0);
var left=0;
var big=0;
var small=0;function init() {
initarrays();
initselects();
}
function initselects() {
document.f1.pc_genre.options.length=0;
for (var i=0;i<bigkinds.length;i++) {
document.f1.pc_genre.options.length++;
document.f1.pc_genre.options[i].text=bigkinds[i];
document.f1.pc_genre.options[i].value=bigvalue[i];
}}function initarrays() {addbig("品牌计算机",1);
addsmall(1,"方正商用机",17);
addsmall(1,"金长城服务器",16);
addsmall(1,"金长城家用机",15);
addsmall(1,"金长城商用机",14);
addsmall(1,"方正家用机",18);
addsmall(1,"方正服务器",19);
addsmall(1,"联想商用机",20);
addsmall(1,"联想家用机",21);
addsmall(1,"联想服务器",22);
addbig("笔记本",2);
addbig("电脑配件",3);
addsmall(3,"软驱",31);
addsmall(3,"光驱",30);
addsmall(3,"声卡",29);
addsmall(3,"显示卡",28);
addsmall(3,"机箱",32);
addsmall(3,"硬盘",27);
addsmall(3,"内存",26);
addsmall(3,"CPU",25);
addsmall(3,"主板",24);
addsmall(3,"键盘",33);
addsmall(3,"鼠标",34);
addsmall(3,"电源",49);
addbig("消耗品",4);
addbig("办公用品",5);
addsmall(5,"传真机",35);
addsmall(5,"打印机",36);
addbig("网络产品",6);
addsmall(6,"网卡",37);
addsmall(6,"集线器",38);
addsmall(6,"交换机",39);
addsmall(6,"ADSL",40);
addsmall(6,"路由器",41);
addsmall(6,"MODEM",48);
addbig("外设",7);
addsmall(7,"CTR显示器",43);
addsmall(7,"液晶显示器",44);
addsmall(7,"针式打印机",45);
addsmall(7,"喷墨打印机",46);
addsmall(7,"激光打印机",47);
}function findindex(seltemp,newvalue) {
for (var i=0;i<seltemp.length;i++)
if (seltemp.options[i].value==newvalue) break;
return i;
}function changebig(newvalue) {
document.f1.pc_genre.selectedIndex=findindex(document.f1.pc_genre,newvalue);
big=newvalue;
updateclassid(document.f1.pc_genre.selectedIndex);}
function changesmall(newvalue) {
document.f1.type.selectedIndex=findindex(document.f1.type,newvalue);
small=newvalue;}
function updateclassid(n) {
document.f1.type.options.length=0;
for (var i=0;i<kinds[n].length;i++) {
document.f1.type.options.length++;
document.f1.type.options[i].text=kinds[n][i];
document.f1.type.options[i].value=values[n][i];
}
document.f1.type.selectedIndex=0;
}function addbig(disptext,newvalue) {
bigkinds.length++;
bigkinds[bigkinds.length-1]=disptext;
bigvalue.length++;
bigvalue[bigvalue.length-1]=newvalue;
kinds.length++;
kinds[kinds.length-1]=new Array(0);
values.length++;
values[values.length-1]=new Array(0);}
function addsmall(n,disptext,newvalue) {
kinds[n-1].length++;
kinds[n-1][kinds[n-1].length-1]=disptext;
values[n-1].length++;
values[n-1][values[n-1].length-1]=newvalue;
}</SCRIPT>
<SELECT
onchange=changebig(this.options[this.selectedIndex].value) name=pc_genre>
</SELECT>
<SELECT
onchange=changesmall(this.options[this.selectedIndex].value) name=type> </SELECT><SCRIPT language=javascript>
init();
changebig(1);
changesmall(1);
</SCRIPT>
解决方案 »
- 请教关于get搜索,火狐下面显示中文
- input框内输入内容,怎么实现回车后自动搜索数据库返回其他input框的内容
- php远程连接mysql
- 在Apache Server 上怎样下载一个目录的所有东西,还是需要用什么工具?
- 删除整个目录的函数问题!!急
- 高薪招聘php资深工程师
- 社区论坛软件专家高薪(5-10K)诚聘开发人员
- 请教PHP论坛哪一种比较好?
- 初学ssl,给点简单的代码看看
- 菜鸟提问::::我想象csdn这样点web开发的php,然后右边的就出现所有的问题
- 有人知道resource socket_create ( int domain, int type, int protocol)这个函数的用法吗,为什么我老是出错?
- 插入数据库问题!
<table width="400" cellspacing="0" cellpadding="0">
<tr>
<td colspan="2" height="42">
<div align="center">新增工作任務</div>
</td>
</tr>
<tr>
<td width="25%">
<div align="right">任務主題</div>
</td>
<td width="75%">
<input type="text" name="contentname" size="35">
</td>
</tr>
<tr>
<td width="25%">
<div align="right">負責人</div>
</td>
<td width="75%">
<select name="depart" onchange="sel(form1.depart,IdArr,TextArr)">
</select>
<select name="userid" >
</select>
</td>
</tr>
<tr>
<td colspan="2" height="44">
<div align="center">
<input type="submit" name="submit" value="保存">
<input type="button" name="Submit2" value="離開" onclick="self.close()">
</div>
</td>
</tr>
</table>
</form>
<?
$R=mysql_query("select departid,departname from depart order by id");
$Num=mysql_num_rows($R);
echo "<script language=javascript>\n";
echo "form1.depart.length=$Num;\n";
echo "IdArr=new Array();\nTextArr=new Array();\n";
$i=0;
while($PArr=mysql_fetch_array($R)){
echo "IdArr[$i]='$PArr[departid]';\n";
echo "TextArr[$i]='$PArr[departname]';\n";
echo "form1.depart.options[$i].value='$PArr[departid]';\n";
echo "form1.depart.options[$i].text='$PArr[departname]';\n";
echo "IdArr[$i]=new Array();\n";
echo "TextArr[$i]=new Array();\n";
$m=0;
$SR=mysql_query("select userid,realname from user where department=$PArr[departid]");
while($SArr=mysql_fetch_array($SR)){
echo "IdArr[$i][$m]='$SArr[userid]';\n";
echo "TextArr[$i][$m]='$SArr[realname]';\n";
$m++;
}
$i++;
}
echo "</script>\n";
?>
<script language=javascript>
sel(form1.depart,IdArr,TextArr);
function sel(select,IdArray,TextArray)
{
index=select.selectedIndex;
form1.userid.length=IdArray[index].length;
for (n=0;n<IdArray[index].length;n++)
{
var op=form1.userid.options[n];
op.value=IdArray[index][n];
op.text=TextArray[index][n];
}
}
</script>更改相關的字段即可
因为我是初学,没用过,我不知道Apache 是否
可以解释得了Java script 脚本。
有没有纯Php写的代码?
php對待它如同對待html一樣
都是先echo然後由瀏覽器來執行