スポンサーリンク

【JavaScript】submitボタンを使わずにpostリクエストを送る

html側

<form name=”frm” action=”/shop/index” method=”post”>
<input type=”hidden” name=”item_id” value=””>
<input type=”hidden” name=”color_id” value=””>

<div><a href=”javascript:void(0);” onClick=”try(‘011111′,2);return false;”><img src=”/image/shop/btn_change.gif” alt=”試着イメージ” width=”95″ height=”24″ /></a></div>

</form>

 

 

js側

function try(item_id, color_id){
//document.frm_tryitem.action=’/shop/index’;
document.frm.item_id.value=item_id;
document.frm.color_id.value=color_id;
document.frm.submit();
}

 

 

aタグでpostリクエストを発火できるので好きな画像設定、それをクリックしてpostできる

 

 

コメント

タイトルとURLをコピーしました