<div class="project_right"> <div class="project_title_right" id="myright"> <script languange="javascript"> var idlist2 = "sel1,sel2,sel3,sel4,sel5,sel6,sel7"; </script> <div class="buy_line"> <div class="buy_one_seled" id="sel1" onclick="buy_divsel_switch(this,'1',idlist2)">¥1元</div> <div class="buy_one_sel" id="sel2" onclick="buy_divsel_switch(this,'2',idlist2)">¥2元</div> <div class="buy_one_sel" id="sel3" onclick="buy_divsel_switch(this,'5',idlist2)">¥5元</div> </div> <div class="buy_line"> <div class="buy_one_sel" id="sel4" onclick="buy_divsel_switch(this,'10',idlist2)">¥10元</div> <div class="buy_one_sel" id="sel5" onclick="buy_divsel_switch(this,'50',idlist2)">¥50元</div> <div class="buy_one_sel" id="sel6" onclick="buy_divsel_switch(this,'100',idlist2)">¥100元</div> </div> <div class="buy_line"> <div class="buy_one_sel" id="sel7" onclick="buy_divsel_switch(this,'',idlist2)">其他</div> <input type="text" name="selmoney" id="selmoney" value="1" maxlength="10" class="buy_one_other_noshow"> </div> <div class="sendArea"> <button class="btn btn-primary" id="btn_tobuy" style="90%;height:40px;margin-top:20px;">打赏一下</button> <div class="shuoshuo">(亲,打赏是没有回报的哟)</div> </div> </div> <!-- project_title_right end-->
//表单数据
function buy_divsel_switch(obj,setvalue,idlist){ var ids = idlist.split(","); var f_obj = document.getElementById("selmoney"); for(i=0;i<ids.length;i++){ var tab = document.getElementById(ids[i]); f_obj.className="buy_one_other_noshow"; if(ids[i]==obj.id){ tab.className = "buy_one_seled"; f_obj.value = setvalue; }else{ tab.className = "buy_one_sel"; } if(obj.id=="sel7"){ f_obj.className="buy_one_other"; f_obj.focus(); } } }
//选择
<script type="text/javascript"> $(function(){ $("#project_btn_act_favorite").click(function(){ Dialog_addTaskFavorite('ad5vs8016n'); }); $("#btn_tobuy").click(function(){ var pid = "ad5vs8016n"; var ptype = "1006"; var gid = pid+"100000"; buy0(pid,ptype,gid,1,document.getElementById("selmoney").value); }); popUPDiv("myright","mymark"); $('#collapseOne').collapse('hide'); });
function buy0(pid,ptype,gid,num,money){ if(!isNumber(money)){ alert(""); return; } if(confirm("")){ var param = "pid="+pid+"&ptype="+ptype+"&gid="+gid+"&num="+num+"&money="+money; projectdobuy(param); return; } }
//确认选择
function projectdobuy(params){ var url; var post; var dataType; var param; url = "/projectcosttodo.html"; post = 'post'; dataType = 'json'; param = params; $.ajax({ "type":post, "url": url, "dataType":dataType, "data":param, "success": function(data){ if(data["status"]=="1"){ var param = "ordernum="+data["order_id"]+"&paymoney="+data["pay_money"]+"&pid="+data["p_id"]; ali_pay_submit(param); }else{ alert(data["msg"]); } } }); }
//ajax确认
//pay
function ali_pay_submit(params){
var url = "/aitaoqian_pay_submit.html?"+params;
location.href = url;
return;
}
这个表单主要是利用session防止重复ajax提交,想法蛮奇特的。网址:http://www.itaoqian.net/