ȨÆäÀÌÁöÁ¦ÀÛ±³½Ç
ȨÆäÀÌÁö Á¦ÀÛ±âÃÊ
±âº»Å±×
ÅÂ±×ÆÁ¸ðÀ½
ű×ÀÚ·á¹æ
Æ÷Åä¼¥°ÁÂ
À¥.°ü·Ã°ÁÂ
PHP°ÁÂ
PHPÆÁ
HTML.CSS
JAVASCRIPT
ASP
JSP
PHP½ÉÈ
C.C++
Ç÷¡½Ã.ActionScript
ÀÚÀ¯°Ô½ÃÆÇ
Áú¹®°Ô½ÃÆÇ
À¯¸Ó°Ô½ÃÆÇ
¿À¶ô½Ç
Tel. 042-353-2371
ÆòÀÏ ¿ÀÀü 9½Ã ~ ¿ÀÈÄ 7½Ã
±â¾÷ÀºÇà
010-8649-6758
¿¹±ÝÁÖ:Á¦ÁÖ»ç¶û(¼ÛÁø¾Æ)
JAVASCRIPT
Ȩ > ȨÆäÀÌÁöÁ¦ÀÛ±³½Ç > JAVASCRIPT
ÀÛ¼ºÀÚ
freewebkorea
Ä«Å×°í¸®
JavaScript
Tutorial
Object
ºñ¹Ð¹øÈ£
Á¦¸ñ
<H2>ÀÔ·Â °ª È£ÃâÇϱâ</H2> <P class=mtext>¾Õ¿¡¼ Input, select µî °ªÀ» ÀÔ·ÂÇÒ ¼ö ÀÖ´Â Element ¿¡ ´ëÇØ ¹è¿ü½À´Ï´Ù¸¸ ÀÔ·ÂµÈ °ªÀ» ºÒ·¯ ¿Ã ¼ö ¾ø´Ù¸é ¾Æ¹« ¼Ò¿ëÀÌ ¾øÀ» °Í ÀÔ´Ï´Ù. ±×·¸°Ô Çϱâ À§Çؼ´Â °¢ ÀÔ·Â Ç׸ñÀÇ °ªÀÌ ¾î¶² ½ÄÀ¸·Î À̸§ÀÌ ºÙ¿© Áö´Â Áö ¾Ë¾Æ¾ß µÇ°Ú½À´Ï´Ù. À̹ø ÆäÀÌÁö¿¡¼´Â ÀÔ·ÂµÈ °ªÀÇ À̸§À» ºÎ¸£´Â ¹æ¹ý°ú text, checkbox, radio button °ú °°Àº Çü½ÄÀÇ µ¥ÀÌÅÍ ´Ù·ç´Â ¹æ¹ý¿¡ ´ëÇØ ¾Ë¾Æ º¸µµ·Ï ÇϰڽÀ´Ï´Ù. ¿ì¼± ¾Æ·¡ÀÇ form À» º¸¸é input TagÀÇ value°¡ <B>text ÀÔ·ÂÇÏ´Â °÷ ÀÔ´Ï´Ù.</B> ·Î µÇ¾î Àִµ¥ ÀÌ °ªÀ» ¾î¶»°Ô ºÎ¸£´À³Ä ÇÏ´Â ¹®Á¦°¡ µÇ°Ú½À´Ï´Ù. ¾Æ·¡ÀÇ ±½°Ô Ç¥½ÃµÈ name °ªÀÌ ÀÌ ¹Ù·Î ±× ¿¼è°¡ µË´Ï´Ù. </P><!-- ÀÔ·Â pre ½ÃÀÛ --><B class=pos>Form</B> <PRE class=input><body> <form action="view.asp" method="post" name="<B><SPAN style="COLOR: #0033cc">sample</SPAN></B>"> <input type="text" name="<SPAN style="COLOR: #2e8b57"><B>text</B></SPAN>" size="30" <B>value</B>="text ÀÔ·ÂÇÏ´Â °÷ ÀÔ´Ï´Ù." /> </form> </body> </PRE><!-- ÀÔ·Â pre ³¡--> <P class=mtext>¾Æ·¡¿Í °°ÀÌ ÁöÁ¤ÇÕ´Ï´Ù.</P><!-- ÀÔ·Â div ½ÃÀÛ --><B>type="text" ÇüÅÂÀÇ value °ª È£ÃâÇϱâ</B> <DIV class=input><B><SPAN style="COLOR: #941919">document</SPAN>.<SPAN style="COLOR: #0033cc">sample</SPAN>.<SPAN style="COLOR: #2e8b57">text</SPAN>.value</B> </DIV><!-- ÀÔ·Â div ³¡--> <P class=mtext>À§ÀÇ Code´Â ¹®¼(document)ÀÇ, sample À̶ó´Â À̸§À» °¡Áø formÀÇ, text¶ó´Â À̸§À» °¡Áø input(text)¿¡ ÀԷµÈ(µÇ´Â), °ª(value) À̶ó°í Ç®¾î¼ ¼³¸íÇÒ ¼ö ÀÖ°Ú±º¿ä. ÀÌ·¸°Ô À§¿Í °°ÀÌ »óÀ§¿¡¼ ÇÏÀ§·Î ÇÑ ´Ü°è¾¿ ³»·Á °¡¸é¼ name ¼Ó¼º °ªÀ» Á¡(.)À¸·Î ¿¬°á ½ÃÄÑ ºÒ·¯ÁÖ¸é µÇ°Ú½À´Ï´Ù. ´ÙÀ½Àº À§ÀÇ ¹æ¹ýÀ¸·Î ÀÔ·ÂÇÏ´Â ³»¿ëÀ» alert °æ°íâ¿¡ ¶ç¿ì´Â ¿¹Á¦¸¦ Çϳª ÇØ º¸Á®... ½ÇÇàÇÑ ´ÙÀ½ ÀԷ¶õ¿¡ »õ·Î¿î ³»¿ëÀ» ÀÔ·ÂÇϰí '°æ°íâ º¸±â' ´ÜÃ߸¦ ´©¸£¸é ÀÔ·ÂÇÑ ³»¿ëÀÌ °æ°íâ¿¡ ³ªÅ¸³³´Ï´Ù.</P><!-- ÀÔ·Â pre ½ÃÀÛ --><B class=pos>ÀÔ·Â</B> <PRE class=input id=alert_input><html> <head> <title>ÀÔ·Â °ªÀ» °æ°íâÀ¸·Î ¶ç¿ì±â</title> <script type="text/javascript"> <!-- function show_message(){ txt = <B>document.sample.text.value</B> alert(txt) } // --> </script> </head> <body> <form action="view.asp" method="post" name="<B><SPAN style="COLOR: #0033cc">sample</SPAN></B>"> <input type="text" name="<SPAN style="COLOR: #2e8b57"><B>text</B></SPAN>" size="30" <B>value</B>="text ÀÔ·ÂÇÏ´Â °÷ ÀÔ´Ï´Ù." /> </form> <input type="button" value="°æ°íâ º¸±â" onclick="show_message()" /> </body> </html> </PRE><!-- ÀÔ·Â pre ³¡--><A href="javascript:copy2Clipboard(alert_input);open_window('../../../include/code_executor.asp');"><IMG alt="ÄÚµå ½ÇÇà Çϱâ" src="http://www.cadvance.org/doc/images/icon/exec_button.gif" border=0></A><BR><BR> <HR class=grayHr> <BR><B>length Method</B> <P class=mtext>length Method´Â JavaScript¿¡¼ ¾ø¾î¼´Â ¾È µÉ Method Áß¿¡ ÇϳªÀÔ´Ï´Ù. Length ¶õ ±æÀ̶ó´Â ¶æ ÀÌÁö¸¸ JavaScript¿¡¼´Â °¹¼ö¸¦ ¼¼¾îÁÖ´Â ¿ªÇÒµµ ÇÕ´Ï´Ù. Áï, ¹®ÀÚ¿ÀÇ ±æÀÌ(String Object¿¡¼ ´Ù·ì´Ï´Ù.)¶óµçÁö, ¹®¼³»ÀÇ °°Àº id¸¦ °¡Áø TagÀÇ °¹¼ö, LinkµÈ imageÀÇ °¹¼ö µîÀ» countÇØÁÖ´Â ¿ªÇÒÀ» ÇÏ°Ô µË´Ï´Ù. ´ÙÀ½Àº length Method¸¦ »ç¿ëÇÏ¿© Form collection ÀÇ web À̶ó´Â À̸§(name)À» °¡Áø input TagÀÌ ¸î °³ ÀÖ´ÂÁö countÇÏ´Â ¿¹Á¦°¡ µÇ°Ú½À´Ï´Ù.</P><!-- ÀÔ·Â pre ½ÃÀÛ --><B class=pos>length Method¸¦ ½Ã¿ëÇÏ¿© object °¹¼ö count Çϱâ</B> <PRE class=input id=counting><html> <head> <title>¸î °³ÀÎÁö Ä«¿îÆ®Çϱâ</title> <script type="text/javascript"> <!-- function count_option(){ alert(document.<B>sample</B>.<B>web</B>.<B>length</B> + " °³ ÀÔ´Ï´Ù.") } // --> </script> </head> <body> <form name="<B>sample</B>"> <input type="checkbox" name="<B>web</B>" value="HTML" />HTML <input type="checkbox" name="<B>web</B>" value="PHP" />PHP <input type="checkbox" name="<B>web</B>" value="ASP" />ASP <input type="button" value="¸î °³?" onclick="count_option()" /> </form> </body> </html> </PRE><!-- ÀÔ·Â pre ³¡--><A href="javascript:copy2Clipboard(counting);open_window('../../../include/code_executor.asp');"><IMG alt="ÄÚµå ½ÇÇà Çϱâ" src="http://www.cadvance.org/doc/images/icon/exec_button.gif" border=0></A><BR><BR> <HR class=grayHr> <BR><B>checked Property¸¦ ÀÌ¿ëÇÏ¿© ¼±ÅÃµÈ radio buttonÀÇ °ª Ãâ·ÂÇϱâ</B> <P class=mtext>radio buttonÀÇ °æ¿ì¿¡´Â 1°³ ¹Û¿¡ ¼±ÅÃÇÒ ¼ö ¾ø±â ¶§¹®¿¡ °£´ÜÇÑ ¹æ¹ýÀ¸·Î ¾î¶² Ç׸ñÀÌ ¼±ÅõǾú´ÂÁö, value °ªÀÌ ¸ÕÁö ¾Ë¾Æ ³¾ ¼ö ÀÖ½À´Ï´Ù. À̶§ »ç¿ëÇÏ´Â °ÍÀÌ ¹Ù·Î checked Property°¡ µÇ°Ú½À´Ï´Ù.</P><!-- ÀÔ·Â pre ½ÃÀÛ --><B class=pos>checked Property¸¦ ÀÌ¿ëÇÏ¿© ¼±ÅÃµÈ radio buttonÀÇ °ª Ãâ·ÂÇϱâ</B> <PRE class=input id=checked_counting><html> <head> <title>¼±ÅÃµÈ radio buttonÀÇ °ª Ãâ·ÂÇϱâ</title> <script type="text/javascript"> <!-- function chk_val(language){ document.sample.lang.value = language document.sample.chk.value = language } // --> </script> </head> <body> <form name="<B>sample</B>"> <input type="radio" name="<B>lang</B>" onclick="chk_val(this.value);" value="HTML" />HTML <input type="radio" name="<B>lang</B>" onclick="chk_val(this.value);" value="PHP" />PHP <input type="radio" name="<B>lang</B>" onclick="chk_val(this.value);" value="ASP" />ASP <br /> <input type="text" name="<B>chk</B>" /><br /><br /> </form> </body> </html> </PRE><!-- ÀÔ·Â pre ³¡--><A href="javascript:copy2Clipboard(checked_counting);open_window('../../../include/code_executor.asp');"><IMG alt="ÄÚµå ½ÇÇà Çϱâ" src="http://www.cadvance.org/doc/images/icon/exec_button.gif" border=0></A><BR><BR> <HR class=grayHr> <BR><B>¸î °³ÀÇ checkbox°¡ check µÇ¾ú´ÂÁö ¾Ë¾Æº¸±â</B> <P class=mtext>checkboxÀÇ °æ¿ì ¿©·¯ °³ÀÇ Ç׸ñ Áß¿¡¼ ¾î¶² °ÍÀ» ¼±ÅÃÇÒÁö, ¶Ç ¸î °³³ª ¼±ÅÃÇÒÁö ¾Ë ¼ö ¾ø±â ¶§¹®¿¡ ¾Õ¿¡ ³ª¿Â length Method¸¦ »ç¿ëÇÏ¿© for ¹Ýº¹¹®À¸·Î checkboxÀÇ °¹¼ö ¸¸Å checked Property·Î ¹Ýº¹ È®ÀÎÇÏ´Â °úÁ¤ÀÌ ÇÊ¿äÇÕ´Ï´Ù. ´Ù¸¥ input typeº¸´Ù ÂÀ º¹ÀâÇϹǷΠÁÖÀÇÇØ¼ º¸¾Æ¾ß µÇ°Ú½À´Ï´Ù.</P><!-- ÀÔ·Â pre ½ÃÀÛ --><B class=pos>length Method¸¦ ½Ã¿ëÇÏ¿© ¼±ÅÃµÈ checkbox °¹¼ö count Çϱâ</B> <PRE class=input id=how_many><html> <head> <title>checkbox°¡ ¸î °³ check µÇ¾ú´ÂÁö Ä«¿îÆ®Çϱâ</title> <script type="text/javascript"> <!-- function checked_count(){ <I class=comment>//checked_count ¶ó´Â À̸§À¸·Î functionÀ» ¸¸µç´Ù.</I> var txt = "" <I class=comment>// ¹®ÀÚ¿À» ¹ÞÀ» º¯¼ö txt ¸¦ ¼±¾ðÇϰí "" ·Î °ªÀ» ÁÖ¾î ¹®ÀÚ¿ ¹ÞÀ» °ø°£È®º¸</I> var chk_count = 0 <I class=comment>// ¸î°³°¡ checkµÇ´ÂÁö countÇÒ º¯¼ö chk_count ¸¦ ¸¸µé°í ÃʱⰪ 0À» ³Ö´Â´Ù.</I> <I class=comment>// nameÀÌ webÀÎ checkboxÀÇ °¹¼ö¸¸Å 1¾¿ Áõ°¡½ÃŰ¸é¼ countÇÑ´Ù.</I> for (i = 0; i < document.sample.web.length; i++){ if (document.sample.web[i].checked){ <I class=comment>// checkbox°¡ ¼±ÅõǾú´Ù¸é</I> chk_count ++ <I class=comment>// º¯¼ö chk_count¸¦ 1 Áõ°¡ ½ÃŲ´Ù.</I> txt = txt + document.sample.web[i].value + " " <I class=comment>// ¼±ÅÃµÈ Ç׸ñÀÇ value¸¦ txt¿¡ ÀúÀåÇÑ´Ù.</I> } } alert(txt + ": " + chk_count + " °³ check µÇ¾ú½À´Ï´Ù.") } // --> </script> </head> <body> <form name="sample"> <input type="checkbox" name="web" value="HTML" />HTML <input type="checkbox" name="web" value="PHP" />PHP <input type="checkbox" name="web" value="ASP" />ASP <input type="button" value="¸î °³?" onclick="checked_count()" /> </form> </body> </html> </PRE><!-- ÀÔ·Â pre ³¡--><A href="javascript:copy2Clipboard(how_many);open_window('../../../include/code_executor.asp');"><IMG alt="ÄÚµå ½ÇÇà Çϱâ" src="http://www.cadvance.org/doc/images/icon/exec_button.gif" border=0></A><BR><BR><BR> <HR class=blackHr>
<H2>ÀÔ·Â °ª È£ÃâÇϱâ</H2> <P class=mtext>¾Õ¿¡¼ Input, select µî °ªÀ» ÀÔ·ÂÇÒ ¼ö ÀÖ´Â Element ¿¡ ´ëÇØ ¹è¿ü½À´Ï´Ù¸¸ ÀÔ·ÂµÈ °ªÀ» ºÒ·¯ ¿Ã ¼ö ¾ø´Ù¸é ¾Æ¹« ¼Ò¿ëÀÌ ¾øÀ» °Í ÀÔ´Ï´Ù. ±×·¸°Ô Çϱâ À§Çؼ´Â °¢ ÀÔ·Â Ç׸ñÀÇ °ªÀÌ ¾î¶² ½ÄÀ¸·Î À̸§ÀÌ ºÙ¿© Áö´Â Áö ¾Ë¾Æ¾ß µÇ°Ú½À´Ï´Ù. À̹ø ÆäÀÌÁö¿¡¼´Â ÀÔ·ÂµÈ °ªÀÇ À̸§À» ºÎ¸£´Â ¹æ¹ý°ú text, checkbox, radio button °ú °°Àº Çü½ÄÀÇ µ¥ÀÌÅÍ ´Ù·ç´Â ¹æ¹ý¿¡ ´ëÇØ ¾Ë¾Æ º¸µµ·Ï ÇϰڽÀ´Ï´Ù. ¿ì¼± ¾Æ·¡ÀÇ form À» º¸¸é input TagÀÇ value°¡ <B>text ÀÔ·ÂÇÏ´Â °÷ ÀÔ´Ï´Ù.</B> ·Î µÇ¾î Àִµ¥ ÀÌ °ªÀ» ¾î¶»°Ô ºÎ¸£´À³Ä ÇÏ´Â ¹®Á¦°¡ µÇ°Ú½À´Ï´Ù. ¾Æ·¡ÀÇ ±½°Ô Ç¥½ÃµÈ name °ªÀÌ ÀÌ ¹Ù·Î ±× ¿¼è°¡ µË´Ï´Ù. </P><!-- ÀÔ·Â pre ½ÃÀÛ --><B class=pos>Form</B> <PRE class=input><body> <form action="view.asp" method="post" name="<B><SPAN style="COLOR: #0033cc">sample</SPAN></B>"> <input type="text" name="<SPAN style="COLOR: #2e8b57"><B>text</B></SPAN>" size="30" <B>value</B>="text ÀÔ·ÂÇÏ´Â °÷ ÀÔ´Ï´Ù." /> </form> </body> </PRE><!-- ÀÔ·Â pre ³¡--> <P class=mtext>¾Æ·¡¿Í °°ÀÌ ÁöÁ¤ÇÕ´Ï´Ù.</P><!-- ÀÔ·Â div ½ÃÀÛ --><B>type="text" ÇüÅÂÀÇ value °ª È£ÃâÇϱâ</B> <DIV class=input><B><SPAN style="COLOR: #941919">document</SPAN>.<SPAN style="COLOR: #0033cc">sample</SPAN>.<SPAN style="COLOR: #2e8b57">text</SPAN>.value</B> </DIV><!-- ÀÔ·Â div ³¡--> <P class=mtext>À§ÀÇ Code´Â ¹®¼(document)ÀÇ, sample À̶ó´Â À̸§À» °¡Áø formÀÇ, text¶ó´Â À̸§À» °¡Áø input(text)¿¡ ÀԷµÈ(µÇ´Â), °ª(value) À̶ó°í Ç®¾î¼ ¼³¸íÇÒ ¼ö ÀÖ°Ú±º¿ä. ÀÌ·¸°Ô À§¿Í °°ÀÌ »óÀ§¿¡¼ ÇÏÀ§·Î ÇÑ ´Ü°è¾¿ ³»·Á °¡¸é¼ name ¼Ó¼º °ªÀ» Á¡(.)À¸·Î ¿¬°á ½ÃÄÑ ºÒ·¯ÁÖ¸é µÇ°Ú½À´Ï´Ù. ´ÙÀ½Àº À§ÀÇ ¹æ¹ýÀ¸·Î ÀÔ·ÂÇÏ´Â ³»¿ëÀ» alert °æ°íâ¿¡ ¶ç¿ì´Â ¿¹Á¦¸¦ Çϳª ÇØ º¸Á®... ½ÇÇàÇÑ ´ÙÀ½ ÀԷ¶õ¿¡ »õ·Î¿î ³»¿ëÀ» ÀÔ·ÂÇϰí '°æ°íâ º¸±â' ´ÜÃ߸¦ ´©¸£¸é ÀÔ·ÂÇÑ ³»¿ëÀÌ °æ°íâ¿¡ ³ªÅ¸³³´Ï´Ù.</P><!-- ÀÔ·Â pre ½ÃÀÛ --><B class=pos>ÀÔ·Â</B> <PRE class=input id=alert_input><html> <head> <title>ÀÔ·Â °ªÀ» °æ°íâÀ¸·Î ¶ç¿ì±â</title> <script type="text/javascript"> <!-- function show_message(){ txt = <B>document.sample.text.value</B> alert(txt) } // --> </script> </head> <body> <form action="view.asp" method="post" name="<B><SPAN style="COLOR: #0033cc">sample</SPAN></B>"> <input type="text" name="<SPAN style="COLOR: #2e8b57"><B>text</B></SPAN>" size="30" <B>value</B>="text ÀÔ·ÂÇÏ´Â °÷ ÀÔ´Ï´Ù." /> </form> <input type="button" value="°æ°íâ º¸±â" onclick="show_message()" /> </body> </html> </PRE><!-- ÀÔ·Â pre ³¡--><A href="javascript:copy2Clipboard(alert_input);open_window('../../../include/code_executor.asp');"><IMG alt="ÄÚµå ½ÇÇà Çϱâ" src="http://www.cadvance.org/doc/images/icon/exec_button.gif" border=0></A><BR><BR> <HR class=grayHr> <BR><B>length Method</B> <P class=mtext>length Method´Â JavaScript¿¡¼ ¾ø¾î¼´Â ¾È µÉ Method Áß¿¡ ÇϳªÀÔ´Ï´Ù. Length ¶õ ±æÀ̶ó´Â ¶æ ÀÌÁö¸¸ JavaScript¿¡¼´Â °¹¼ö¸¦ ¼¼¾îÁÖ´Â ¿ªÇÒµµ ÇÕ´Ï´Ù. Áï, ¹®ÀÚ¿ÀÇ ±æÀÌ(String Object¿¡¼ ´Ù·ì´Ï´Ù.)¶óµçÁö, ¹®¼³»ÀÇ °°Àº id¸¦ °¡Áø TagÀÇ °¹¼ö, LinkµÈ imageÀÇ °¹¼ö µîÀ» countÇØÁÖ´Â ¿ªÇÒÀ» ÇÏ°Ô µË´Ï´Ù. ´ÙÀ½Àº length Method¸¦ »ç¿ëÇÏ¿© Form collection ÀÇ web À̶ó´Â À̸§(name)À» °¡Áø input TagÀÌ ¸î °³ ÀÖ´ÂÁö countÇÏ´Â ¿¹Á¦°¡ µÇ°Ú½À´Ï´Ù.</P><!-- ÀÔ·Â pre ½ÃÀÛ --><B class=pos>length Method¸¦ ½Ã¿ëÇÏ¿© object °¹¼ö count Çϱâ</B> <PRE class=input id=counting><html> <head> <title>¸î °³ÀÎÁö Ä«¿îÆ®Çϱâ</title> <script type="text/javascript"> <!-- function count_option(){ alert(document.<B>sample</B>.<B>web</B>.<B>length</B> + " °³ ÀÔ´Ï´Ù.") } // --> </script> </head> <body> <form name="<B>sample</B>"> <input type="checkbox" name="<B>web</B>" value="HTML" />HTML <input type="checkbox" name="<B>web</B>" value="PHP" />PHP <input type="checkbox" name="<B>web</B>" value="ASP" />ASP <input type="button" value="¸î °³?" onclick="count_option()" /> </form> </body> </html> </PRE><!-- ÀÔ·Â pre ³¡--><A href="javascript:copy2Clipboard(counting);open_window('../../../include/code_executor.asp');"><IMG alt="ÄÚµå ½ÇÇà Çϱâ" src="http://www.cadvance.org/doc/images/icon/exec_button.gif" border=0></A><BR><BR> <HR class=grayHr> <BR><B>checked Property¸¦ ÀÌ¿ëÇÏ¿© ¼±ÅÃµÈ radio buttonÀÇ °ª Ãâ·ÂÇϱâ</B> <P class=mtext>radio buttonÀÇ °æ¿ì¿¡´Â 1°³ ¹Û¿¡ ¼±ÅÃÇÒ ¼ö ¾ø±â ¶§¹®¿¡ °£´ÜÇÑ ¹æ¹ýÀ¸·Î ¾î¶² Ç׸ñÀÌ ¼±ÅõǾú´ÂÁö, value °ªÀÌ ¸ÕÁö ¾Ë¾Æ ³¾ ¼ö ÀÖ½À´Ï´Ù. À̶§ »ç¿ëÇÏ´Â °ÍÀÌ ¹Ù·Î checked Property°¡ µÇ°Ú½À´Ï´Ù.</P><!-- ÀÔ·Â pre ½ÃÀÛ --><B class=pos>checked Property¸¦ ÀÌ¿ëÇÏ¿© ¼±ÅÃµÈ radio buttonÀÇ °ª Ãâ·ÂÇϱâ</B> <PRE class=input id=checked_counting><html> <head> <title>¼±ÅÃµÈ radio buttonÀÇ °ª Ãâ·ÂÇϱâ</title> <script type="text/javascript"> <!-- function chk_val(language){ document.sample.lang.value = language document.sample.chk.value = language } // --> </script> </head> <body> <form name="<B>sample</B>"> <input type="radio" name="<B>lang</B>" onclick="chk_val(this.value);" value="HTML" />HTML <input type="radio" name="<B>lang</B>" onclick="chk_val(this.value);" value="PHP" />PHP <input type="radio" name="<B>lang</B>" onclick="chk_val(this.value);" value="ASP" />ASP <br /> <input type="text" name="<B>chk</B>" /><br /><br /> </form> </body> </html> </PRE><!-- ÀÔ·Â pre ³¡--><A href="javascript:copy2Clipboard(checked_counting);open_window('../../../include/code_executor.asp');"><IMG alt="ÄÚµå ½ÇÇà Çϱâ" src="http://www.cadvance.org/doc/images/icon/exec_button.gif" border=0></A><BR><BR> <HR class=grayHr> <BR><B>¸î °³ÀÇ checkbox°¡ check µÇ¾ú´ÂÁö ¾Ë¾Æº¸±â</B> <P class=mtext>checkboxÀÇ °æ¿ì ¿©·¯ °³ÀÇ Ç׸ñ Áß¿¡¼ ¾î¶² °ÍÀ» ¼±ÅÃÇÒÁö, ¶Ç ¸î °³³ª ¼±ÅÃÇÒÁö ¾Ë ¼ö ¾ø±â ¶§¹®¿¡ ¾Õ¿¡ ³ª¿Â length Method¸¦ »ç¿ëÇÏ¿© for ¹Ýº¹¹®À¸·Î checkboxÀÇ °¹¼ö ¸¸Å checked Property·Î ¹Ýº¹ È®ÀÎÇÏ´Â °úÁ¤ÀÌ ÇÊ¿äÇÕ´Ï´Ù. ´Ù¸¥ input typeº¸´Ù ÂÀ º¹ÀâÇϹǷΠÁÖÀÇÇØ¼ º¸¾Æ¾ß µÇ°Ú½À´Ï´Ù.</P><!-- ÀÔ·Â pre ½ÃÀÛ --><B class=pos>length Method¸¦ ½Ã¿ëÇÏ¿© ¼±ÅÃµÈ checkbox °¹¼ö count Çϱâ</B> <PRE class=input id=how_many><html> <head> <title>checkbox°¡ ¸î °³ check µÇ¾ú´ÂÁö Ä«¿îÆ®Çϱâ</title> <script type="text/javascript"> <!-- function checked_count(){ <I class=comment>//checked_count ¶ó´Â À̸§À¸·Î functionÀ» ¸¸µç´Ù.</I> var txt = "" <I class=comment>// ¹®ÀÚ¿À» ¹ÞÀ» º¯¼ö txt ¸¦ ¼±¾ðÇϰí "" ·Î °ªÀ» ÁÖ¾î ¹®ÀÚ¿ ¹ÞÀ» °ø°£È®º¸</I> var chk_count = 0 <I class=comment>// ¸î°³°¡ checkµÇ´ÂÁö countÇÒ º¯¼ö chk_count ¸¦ ¸¸µé°í ÃʱⰪ 0À» ³Ö´Â´Ù.</I> <I class=comment>// nameÀÌ webÀÎ checkboxÀÇ °¹¼ö¸¸Å 1¾¿ Áõ°¡½ÃŰ¸é¼ countÇÑ´Ù.</I> for (i = 0; i < document.sample.web.length; i++){ if (document.sample.web[i].checked){ <I class=comment>// checkbox°¡ ¼±ÅõǾú´Ù¸é</I> chk_count ++ <I class=comment>// º¯¼ö chk_count¸¦ 1 Áõ°¡ ½ÃŲ´Ù.</I> txt = txt + document.sample.web[i].value + " " <I class=comment>// ¼±ÅÃµÈ Ç׸ñÀÇ value¸¦ txt¿¡ ÀúÀåÇÑ´Ù.</I> } } alert(txt + ": " + chk_count + " °³ check µÇ¾ú½À´Ï´Ù.") } // --> </script> </head> <body> <form name="sample"> <input type="checkbox" name="web" value="HTML" />HTML <input type="checkbox" name="web" value="PHP" />PHP <input type="checkbox" name="web" value="ASP" />ASP <input type="button" value="¸î °³?" onclick="checked_count()" /> </form> </body> </html> </PRE><!-- ÀÔ·Â pre ³¡--><A href="javascript:copy2Clipboard(how_many);open_window('../../../include/code_executor.asp');"><IMG alt="ÄÚµå ½ÇÇà Çϱâ" src="http://www.cadvance.org/doc/images/icon/exec_button.gif" border=0></A><BR><BR><BR> <HR class=blackHr>
÷ºÎÆÄÀÏ
°ßÀû°è»êÇϱâ
ÀÛ¾÷ÀÇ·Ú
°ßÀû¹®ÀÇ
°øÁö»çÇ×