js提交form(动态参数)

来源:互联网 发布:contact java 编辑:程序博客网 时间:2024/06/03 16:12

 from: http://topic.csdn.net/u/20090407/18/6b4b7ecd-02c6-4fd8-b7f4-df0be4af8ac7.html

 


//get selected value and put into an html element
function getSelectedValue(selector, tips){
 var target = document.getElementById(tips);
 target.value = selector.value;
 //alert('value: '+target.value);
}
//submit a form, by building url with value of html element
function viewDetailById(formid,action_url,tips){
 var param = document.getElementById(tips).value;
 if(param.length<1){
  alert('please select an option!');
  return false;
 }
 
 var f = document.getElementById(formid);
 f.action=action_url+param;
 //alert('action: '+f.action);
 f.submit();
}