<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>수량 증가/감소 (JQuery로 작성.)</title> <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script> <script type="text/javascript"> /** * 수량 증가/감소 (JQuery로 작성.) */ function modifyProductQuantity(id, quantity){ if(isNaN($("#"+id).val())){ alert( '숫자만 입력가능 합니다.' ); $("#"+id).focus(); $("#"+id).val(0); return; } //var v = parseFloat($("#"+id).val())+parseFloat(quantity); //$("#"+id).val(Math.round(v*10)/10); var q = parseInt($("#"+id).val())+parseInt(quantity); $("#"+id).val(q);
};
</script> </head> <body> 수량 : <input name="quantity" id="quantity" style="vertical-align:middle; text-align:right" size="5" maxlength="4" value="0" /> <img style="vertical-align:middle;" alt="수량 증가 감소" src="btn_cnt.gif" usemap="#map_name_quantity"/> <map id="map_name_quantity" name="map_name_quantity"> <area href="javascript:modifyProductQuantity('quantity',1);" shape="rect" alt="수량 증가" coords="0,0,9,10"/> <area href="javascript:modifyProductQuantity('quantity',-1);" shape="rect" alt="수량 감소" coords="0,10,9,20"/> </map>
</body> </html> |
|