搜索选项主要有以下内容和功能如下,下拉列表中有“产品”和“资料”选项,后面是输入文本框和提交按钮,如何实现在选择“产品”点击按钮时是就搜索“产品”,而在选择“资料”点击按钮时时就搜索“资料”,这应该是很简单的问题,怎么搞,我主要是不熟悉JavaScript代码?
<html>
<head>
<title>选择搜索CsrCode.Cn</title>
</head>
<body>
<form>
<select name="">
<option>产品</option>
<option>资料</option>
</select>
<input name="" type="text" />
<input name="" type="button" />
</form>
</body>
</html>
<html>
<head>
<title>选择搜索CsrCode.Cn</title>
</head>
<body>
<form>
<select name="">
<option>产品</option>
<option>资料</option>
</select>
<input name="" type="text" />
<input name="" type="button" />
</form>
</body>
</html>
解决方案 »
- 怎么才能控制html5中的audio控件的音乐的暂停和开始
- DOM问题
- jQuery中filter的使用
- 谁用过ComponentArt 控件,其中它的Dialog控件onFocus事件怎么用?请教大家了,谢谢!
- 怎样用javascript从数据库里读数啊
- 如何在Ext 中textfield后面显示提示信息
- 如何用javascript修改层的颜色???
- 求,在一个INPUT中直接输入123*4856+(123*45),再在另一个INPUT中得到计算的值
- 如何用JAVASCRIPT对数据库进行删除一条记录的操作?
- 如何写一个随时抽提目HTML-求代码
- jquery click事件不执行问题
- 关于字符串提取的简单问题
<html>
<head>
<title>选择搜索CsrCode.Cn</title>
<script language="javascript" type="text/javascript">
function huihui()
{
alert("aa");
var textattr=document.getElementById("kk");
var sellectattr=document.getElementById("fun");
alert(sellectattr.length);
for(var i=0;i<sellectattr.length;i++)
{
if(sellectattr[i].selected==true)
{
textattr.value=sellectattr[i].innerHTML;
}
}
alert("aa");
}</script>
</head>
<body>
<form>
<select name="" id="fun">
<option></option>
<option>产品</option>
<option>资料</option>
</select>
<input name="" type="text" id="kk"/>
<input name="" type="button" onclick="javascript:huihui();"/>
</form>
</body>
</html>
那么你只要根据当前选择把转跳和传递参数,传递到对应php不就ok了。就是if判断么。
你的基础目前缺乏得太多,不是能靠问问题解决的,最好先看看系统的开发书籍(我感觉我都快成图书义务宣传员了).
<select name="skind">
<option>产品</option>
<option>资料</option>
</select>
<input name="" type="text" />
<input name="" type="button" />
</form>后台PHP里:
<?php echo $_POST["skind"]; ?>楼主下面说的,提交到不同的PHP页面.这个是很笨的方法.学PHP,应该学到模板和控制器.提交到同一个控制器页面,按照行为参数,由这个控制器页面再去调用相应的行为,在里面再读取相应模板.这样,维护的时候,只需要修改这个控制器,而无需再改动HTML.
<head>
<title>选择搜索CsrCode.Cn</title>
<script language="javascript" type="text/javascript">
function huihui()
{
var textattr=document.getElementById("kk");
var sellectattr=document.getElementById("fun"); for(var i=0;i<sellectattr.length;i++)
{
if(sellectattr[i].selected==true)
{
if(sellectattr[i].innerHTML=='产品')
{
window.location.href="b.php?attr="+textattr.value;
}
else if(sellectattr[i].innerHTML=='资料')
{
window.location.href="c.php?attr="+textattr.value;
}
}
}}</script>
</head>
<body>
<form>
<select name="" id="fun">
<option></option>
<option>产品</option>
<option>资料</option>
</select>
<input name="" type="text" id="kk"/>
<input name="" type="button" onclick="javascript:huihui();"/>
</form>
</body>
</html>
b.php/c.php
<?phpprint_r($_GET);
?>
<head>
<title>多搜索跳转</title>
</head>
<body>
<form id="mainform" name="mainform" method="post" action="?">
<label>
<input name="mkey" type="text" id="mkey" value="" />
</label>
<label>
<select name="allsear" id="allsear">
<option value="1">产品</option>
<option value="2">资料</option>
</select>
</label>
<label>
<input type="button" name="button" id="button" value="搜索" onClick="subs();" />
</label>
</form>
<script>
function subs()
{
var myvalue=document.getElementById("allsear").options[document.getElementById("allsear").selectedIndex].value;
var keytext=document.mainform.mkey.value;
var urls;
switch(myvalue)
{
case "1":
urls="http://localhost/ctdeb/product.php?kind=%25&brand=%25&kws="+keytext;
break
case "2":
urls="http://localhost/ctdeb/data.php?kind=%25&kws="+keytext;
break}
window.location.href=urls;
}
</script>
</html>