답변 2개
채택된 답변
+20 포인트
8년 전
http://iyoon.github.io/jekyll/update/2015/12/15/javscript-form.html">http://iyoon.github.io/jekyll/update/2015/12/15/javscript-form.html
저에겐 어려운 것이라 잘 모르겠지만 위의 주소를 한번 확인 해 보시면 포로포토님은 할 수 있으실듯..
로그인 후 평가할 수 있습니다
댓글을 작성하려면 로그인이 필요합니다.
8년 전
자바 스크립트 부분에
jquery 사용 중 이라면
</p><p>//html 부분</p><p><span style="font-family: Consolas, "Courier New", monospace; font-size: 14px; white-space: pre; background-color: rgb(255, 255, 255); color: rgb(128, 0, 0);"><input</span><span style="font-family: Consolas, "Courier New", monospace; font-size: 14px; white-space: pre; background-color: rgb(255, 255, 255);"> name="인풋네임" </span><font color="#ff0000" style="font-family: Consolas, "Courier New", monospace; font-size: 14px; white-space: pre; background-color: rgb(255, 255, 255);">중략</font><span style="font-family: Consolas, "Courier New", monospace; font-size: 14px; white-space: pre; background-color: rgb(255, 255, 255);"> </span><font color="#ff0000" style="font-family: Consolas, "Courier New", monospace; font-size: 14px; white-space: pre; background-color: rgb(255, 255, 255);">....</font><span style="font-family: Consolas, "Courier New", monospace; font-size: 14px; white-space: pre; background-color: rgb(255, 255, 255);"> </span><span style="font-family: Consolas, "Courier New", monospace; font-size: 14px; white-space: pre; background-color: rgb(255, 255, 255); color: rgb(128, 0, 0);">/></span> </p><p> </p><p>//자바스크립트 부분</p><div style="background-color: rgb(255, 255, 255); font-family: Consolas, "Courier New", monospace; font-size: 14px; line-height: 19px; white-space: pre;"><span style="color: #795e26;">$</span>(<span style="color: #a31515;">"input[name=인풋네임]"</span>).<span style="color: #795e26;">keydown</span>(<span style="color: #0000ff;">function</span> (<span style="color: #001080;">key</span>) {</div><div style="background-color: rgb(255, 255, 255); font-family: Consolas, "Courier New", monospace; font-size: 14px; line-height: 19px; white-space: pre; margin-left: 40px;">//13번이 엔터값 입니다.
</div><div style="background-color: rgb(255, 255, 255); font-family: Consolas, "Courier New", monospace; font-size: 14px; line-height: 19px; white-space: pre;"><div style="line-height: 19px;"> <span style="color: #af00db;">if</span>(<span style="color: #001080;">key</span>.<span style="color: #001080;">keyCode</span> == <span style="color: #09885a;">13</span>){</div><div style="line-height: 19px; margin-left: 80px;">//계산하기 로직 넣기</div><div style="line-height: 19px;"> }</div></div><div style="background-color: rgb(255, 255, 255); font-family: Consolas, "Courier New", monospace; font-size: 14px; line-height: 19px; white-space: pre;"><div style="line-height: 19px;">});</div></div><div style="background-color: rgb(255, 255, 255); font-family: Consolas, "Courier New", monospace; font-size: 14px; line-height: 19px; white-space: pre;">
인풋네임에 해당 폼 입력하시구요
javascript 사용이라면
</div><div style="background-color: rgb(255, 255, 255); font-family: Consolas, "Courier New", monospace; font-size: 14px; line-height: 19px; white-space: pre;">//html 부분</div><div style="background-color: rgb(255, 255, 255); font-family: Consolas, "Courier New", monospace; font-size: 14px; line-height: 19px; white-space: pre;"><div style="line-height: 19px;"><span style="color: #800000;"><input</span> <font color="#ff0000">중략</font> <font color="#ff0000">....</font> <span style="color: #ff0000;">onkeyup</span>=<span style="color: #0000ff;">'submitCalc(event)'</span><span style="color: #800000;"> /></span></div><div style="line-height: 19px;"><span style="color: #800000;">
</span></div><div style="line-height: 19px;"><font color="#800000">//스크립트 부분</font></div><div style="line-height: 19px;"><div style="line-height: 19px;"><span style="color: #0000ff;">function</span> <span style="color: rgb(0, 0, 255);">submitCalc</span>(<span style="color: #001080;">event</span>) {</div></div><div style="line-height: 19px;"><div style="line-height: 19px;"><div style="margin-left: 40px;"><span style="color: #001080;">event</span> = <span style="color: #001080;">event</span> || <span style="color: #001080;">window</span>.<span style="color: #001080;">event</span>;</div><div> <span style="color: #0000ff;">var</span> <span style="color: #001080;">keyID</span> = (<span style="color: #001080;">event</span>.<span style="color: #001080;">which</span>) ? <span style="color: #001080;">event</span>.<span style="color: #001080;">which</span> : <span style="color: #001080;">event</span>.<span style="color: #001080;">keyCode</span>;</div><div><div style="line-height: 19px; margin-left: 40px;"><span style="color: #af00db;">if</span> ( <span style="color: #001080;">keyID</span> == <font color="#09885a">13</font>){</div><div style="line-height: 19px; margin-left: 80px;">//계산하는 서브밋 부분</div><div style="line-height: 19px; margin-left: 40px;">} </div></div></div></div><div style="line-height: 19px;"><span style="color: #800000;">}</span></div></div><div style="background-color: rgb(255, 255, 255); font-family: Consolas, "Courier New", monospace; font-size: 14px; line-height: 19px; white-space: pre;">
이렇게 하시면 되겠습니다.
로그인 후 평가할 수 있습니다
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인