Baidu free code
<SCRIPT language=javascript>function g(formname) {var url = "http://www.baidu.com/baidu";if (formname.s[1].checked) { formname.ct.value = "2097152";}else { formname.ct.value = "0";}formname.action = url;return true;}</SCRIPT><form name="f1" onsubmit="return g(this)"><table bgcolor="#FFFFFF" style="font-size:9pt;"><tr height="60"><td valign="top"><img src="http://img.baidu.com/img/logo-137px.gif" border="0" alt="baidu"></td><td><input name=word size="30" maxlength="100"><input type="submit" value="百度搜索"><br><input name=tn type=hidden value="bds"><input name=cl type=hidden value="3"><input name=ct type=hidden><input name=si type=hidden value="www.baidu.com"><input name=s type=radio> 互联网<input name=s type=radio checked> www.baidu.com</td></tr></table></form>
Do you want code comments?
function g(formname) {var url = "http://www.baidu.com/baidu";//设个默认变量urlif (formname.s[1].checked) {//查找formname里面第二个name为s的input是不是被选中 formname.ct.value = "2097152";//如果是formmname里面name为ct的input的值设为2097152}else { formname.ct.value = "0";//没选中的话设为0}formname.action = url;//formname的action(就是提交地址)指向urlreturn true;}
<form name="f1" onsubmit="return g(this)">