<html>
<head>
<title>测试</title>
<script>
//单选按钮点击事件
function clickRadio()
{
var radioGroup = document.getElementsByName('s'); //点击语文
if(event.srcElement.value == "语文")
{
//判断搜索框
if(juBlank())
{
window.open("http://123.com/yuwen","_blank");
}
else
{
alert("请填写搜索条件");
return;
}
}
//点击数学
else if(event.srcElement.value == "数学")
{
//判断搜索框
if(juBlank())
{
window.open("http://123.com/shuxue","_blank");
}
else
{
alert("请填写搜索条件");
return;
}
}
//点击英文
else if(event.srcElement.value == "英语")
{
//判断搜索框
if(juBlank())
{
window.open("http://123.com/yingyu","_blank");
}
else
{
alert("请填写搜索条件");
return;
}
}
}//判断搜索框是否为空,为空返回false,不为空返回true
function juBlank()
{
if(document.getElementById('word').value == "")
{
return false;
}
else
{
return true;
}
}
</script>
</head
<body>
<form name="form1" method="post" action=""> <input type="text" name="word">
<input type="submit" name="Submit" value="搜索"> <input name="s" type="radio" value="语文" onclick="clickRadio()">语文
<input type="radio" name="s" value="数学" onclick="clickRadio()">数学
<input type="radio" name="s" value="英语" onclick="clickRadio()">英语 </form>
</body>
</html>
<head>
<title>测试</title>
<script>
//单选按钮点击事件
function clickRadio()
{
var radioGroup = document.getElementsByName('s'); //点击语文
if(event.srcElement.value == "语文")
{
//判断搜索框
if(juBlank())
{
window.open("http://123.com/yuwen","_blank");
}
else
{
alert("请填写搜索条件");
return;
}
}
//点击数学
else if(event.srcElement.value == "数学")
{
//判断搜索框
if(juBlank())
{
window.open("http://123.com/shuxue","_blank");
}
else
{
alert("请填写搜索条件");
return;
}
}
//点击英文
else if(event.srcElement.value == "英语")
{
//判断搜索框
if(juBlank())
{
window.open("http://123.com/yingyu","_blank");
}
else
{
alert("请填写搜索条件");
return;
}
}
}//判断搜索框是否为空,为空返回false,不为空返回true
function juBlank()
{
if(document.getElementById('word').value == "")
{
return false;
}
else
{
return true;
}
}
</script>
</head
<body>
<form name="form1" method="post" action=""> <input type="text" name="word">
<input type="submit" name="Submit" value="搜索"> <input name="s" type="radio" value="语文" onclick="clickRadio()">语文
<input type="radio" name="s" value="数学" onclick="clickRadio()">数学
<input type="radio" name="s" value="英语" onclick="clickRadio()">英语 </form>
</body>
</html>
我再发一遍。<html>
<head>
<title>测试</title>
<script>
//单选按钮点击事件
function clickRadio()
{
var radioGroup = document.getElementsByName('s'); //点击语文
if(event.srcElement.value == "语文")
{
//判断搜索框
if(juBlank())
{
window.open("http://123.com/yuwen","_blank");
}
else
{
alert("请填写搜索条件");
return;
}
}
//点击数学
else if(event.srcElement.value == "数学")
{
//判断搜索框
if(juBlank())
{
window.open("http://123.com/shuxue","_blank");
}
else
{
alert("请填写搜索条件");
return;
}
}
//点击英文
else if(event.srcElement.value == "英语")
{
//判断搜索框
if(juBlank())
{
window.open("http://123.com/yingyu","_blank");
}
else
{
alert("请填写搜索条件");
return;
}
}
}//判断搜索框是否为空,为空返回false,不为空返回true
function juBlank()
{
if(document.getElementById('word').value == "")
{
return false;
}
else
{
return true;
}
}
</script>
</head
<body>
<form name="form1" method="post" action=""> <input type="text" name="word">
<input type="submit" name="Submit" value="搜索"> <input name="s" type="radio" value="语文" onclick="clickRadio()">语文
<input type="radio" name="s" value="数学" onclick="clickRadio()">数学
<input type="radio" name="s" value="英语" onclick="clickRadio()">英语 </form>
</body>
</html>
var form = document.forms['form1']; //获取表单对象.form.submit(); //提交表单.
你要实现的功能,就是在适当的地方调用 form.submit(); 进行表单提交.
这里有一个例子,希望对你有用:
http://www.w3schools.com/js/tryit.asp?filename=try_dom_form_submit
再麻烦您把我发的前两个删掉....
<html>
<head>
<title>测试</title>
<script>
//单选按钮点击事件
function clickRadio()
{
var radioGroup = document.getElementsByName('s'); //判断搜索框
if(!juBlank())
{
alert("请填写搜索条件");
return;
}
//点击语文
if(event.srcElement.value == "语文")
{
window.open("http://123.com/yuwen","_blank");
}
//点击数学
else if(event.srcElement.value == "数学")
{
window.open("http://123.com/shuxue","_blank");
}
//点击英文
else if(event.srcElement.value == "英语")
{
window.open("http://123.com/yingyu","_blank");
}
}//判断搜索框是否为空,为空返回false,不为空返回true
function juBlank()
{
if(document.getElementById('word').value == "")
{
return false;
}
else
{
return true;
}
}
</script>
</head
<body>
<form name="form1" method="post" action=""> <input type="text" name="word">
<input type="submit" name="Submit" value="搜索"> <input name="s" type="radio" value="语文" onclick="clickRadio()">语文
<input type="radio" name="s" value="数学" onclick="clickRadio()">数学
<input type="radio" name="s" value="英语" onclick="clickRadio()">英语 </form>
</body>
</html>