生活随笔
收集整理的這篇文章主要介紹了
[ js处理表单 ]:保存、提交
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
作者:yan
<script type="text/javascript"><!--//=================綁定保存start=======================================$("#save_button").click(function() {//var bln = validateFormAttr({formId:"form_div"});//if( !bln ) return false;var el_type="", el_name="", el_value="", param="",checkMark="";$("#form_div").find(":input,select").each(function() {el_type=$(this).attr("type");el_name=$(this).attr("name");if(el_type === "textarea") {el_value = $(this).text();param += el_name+"="+el_value+"&";} else if (el_type === "radio" || el_type === "checkbox") {checkMark = $(this).attr("checked");if(checkMark){el_value = $(this).val();param += el_name+"="+el_value+"&";}} else {el_value = $(this).val();param += el_name+"="+el_value+"&";}});if(param.length>0){param = param.substring(0,param.length-1);}//alert(param);$.ajax({url: "${base}/odf/ajax_odfLcdAction_save.action",data: param,type: "post",dataType: "json",async: true,success: function(data, statuText) {if(data.success) {alert(data.msg);} else {alert(data.msg);}}});});//=================綁定保存 end=======================================//--></script>
總結
以上是生活随笔為你收集整理的[ js处理表单 ]:保存、提交的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。