ȸ¿ø°¡ÀԡžÆÀ̵ð/ºñ¹øã±â
ȨÀ¸·Î


PHP À̸§ÀÌ °°Àº Æûű×(Form Tag)ÀÇ °ª(value) ó¸®Çϱâ
12³â Àü
Æûű×(<form></form>)³»¿¡ ÀÖ´Â INPUT ű×(INPUT BOX), üũ¹Ú½º ű×(CHECK BOX) µîµî¿¡ µ¿ÀÏÇÑ À̸§ÀÌ »ç¿ëµÈ °æ¿ì PHP¿¡¼­´Â ASP, JSP ¿Í´Â Á» ´Ù¸£°Ô 󸮸¦ ÇØÁà¾ß ÇÕ´Ï´Ù.

¾Æ·¡´Â À̸§ÀÌ °°Àº INPUT űװ¡ ¿©·¯°³°¡ »ðÀԵǾî ÀÖ´Â html ±âº» ÆäÀÌÁöÀÔ´Ï´Ù. ´«¿©°Ü º¸½Ç ºÎºÐÀº INPUT ű×ÀÇ
À̸§(name)ÀÔ´Ï´Ù.

<html>
<head>
<title>www.webmadang.net</title>
<meta http-equiv="Content-Type" content="text/html; charset=euc-kr">
</head>
<body>
<form name="form" method="POST" action="addtext_test.php">
<input type="text" name="addText" size="20"><br>
<input type="text" name="addText" size="20"><br>
<input type="text" name="addText" size="20"><br>
<input type="text" name="addText" size="20"><br>
<input type="text" name="addText" size="20"><br>
<input type="submit" name="button" value="Àü ¼Û">
</form>
</body>
</html>



ASP,JSP¿¡¼­´Â À§¿Í °°ÀÌ À̸§À» Á¤Çؼ­ ó¸®Çصµ µÇÁö¸¸ PHP¿¡¼­´Â À§¿Í °°Àº °æ¿ì INPUT ű×ÀÇ À̸§À» ¹è¿­ ÇüÅ·Π¸¸µé¾î Áà¾ß ÇÕ´Ï´Ù. ¾Æ·¡´Â INPUT ű×ÀÇ À̸§À» ¹è¿­ ÇüÅ·Π¹Ù²Û ¿¹ÀÔ´Ï´Ù.

<!---- Àü¼ÛÇÒ ÆäÀÌÁö --->
<html>
<head>
<title>www.webmadang.net</title>
<meta http-equiv="Content-Type" content="text/html; charset=euc-kr">
</head>
<body>
<form name="form" method="POST" action="addtext_test.php">
<input type="text" name="addText[]" size="20"><br>
<input type="text" name="addText[]" size="20"><br>
<input type="text" name="addText[]" size="20"><br>
<input type="text" name="addText[]" size="20"><br>
<input type="text" name="addText[]" size="20"><br>
<input type="submit" name="button" value="Àü ¼Û">
</form>
</body>
</html>


Àü¼Û(submit) ¹öÆ°¿¡ ÀÇÇؼ­ Àü¼ÛÀÌ ÀÌ·ç¾îÁö¸é ¹Þ´Â PHP ÆäÀÌÁö¿¡¼­ 󸮴 ¾ÆÁÖ °£´ÜÇÕ´Ï´Ù.


<?php
//¹Þ´Â ÆäÀÌÁö

  $addText = $_REQUEST[addText];
  $addText = implode(',',$addText);
  echo $addText;

?>  


³Ñ°ÜÁø °ªÀº ¹è¿­·Î ÀúÀåµÇ°í implode ³ª join ÇÔ¼ö¸¦ ÀÌ¿ëÇؼ­ ¹è¿­¿¡ Ư¼ö¹®ÀÚ¸¦ »ðÀÔÇÏ¿© ÇÕÃÄÁÖ½Ã¸é µË´Ï´Ù.
³Ñ°ÜÁø °ªÀº ¾Æ·¡¿Í °°ÀÌ count ¶Ç´Â sizeof ÇÔ¼ö¸¦ ÀÌ¿ëÇؼ­ °³º°ÀûÀ¸·Î È®ÀÎ ÇÒ ¼öµµ ÀÖ½À´Ï´Ù.



<?php
//¹Þ´Â ÆäÀÌÁö

  $addText = $_REQUEST[addText];
  for($i=0;$i<count($addText);$i++)
  {
    echo $addText[$i]."<br>\n";
  }

?>  


PHP¿¡¼­ À̸§ÀÌ µ¿ÀÏÇÑ Æûű×(Form Tag) ³»ÀÇ °ª(value) ó¸®ÇϱâÀÇ ÇÙ½ÉÀº µ¿ÀÏÇÑ À̸§À» °°´Â ű×ÀÇ °ªÀ» ¹è¿­·Î Àâ¾Æ ÁÖ´Â °ÍÀÔ´Ï´Ù.

±×·³ ¹è¿­Çü½ÄÀ¸·Î À̸§À» Àâ¾ÆÁØ INPUT ű×ÀÇ °ªÀ» »ç¿ëÀÚ°¡ ÀÔ·ÂÇÏÁö ¾ÊÀº °æ¿ì¿¡ ÀÚ¹Ù½ºÅ©¸³Æ®¿¡¼­ 󸮴 ¾î¶»°Ô
ÇÒ±î¿ä?


document.form.elements["addText[]"][0].value;




INPUT ÅÂ±× Áß °¡Àå ù¹ø°´Â À§¿Í °°ÀÌ Á¢±ÙÇÒ ¼ö ÀÖ½À´Ï´Ù. ¾Æ´Ï¸é ¾Æ·¡ÀÇ ÀÚ¹Ù½ºÅ©¸³Æ® ¿¹Á¦¿Í °°ÀÌ Ã³¸®ÇÒ ¼öµµ ÀÖ½À´Ï´Ù.

<html>
<head>
<title>www.webmadang.net</title>
<meta http-equiv="Content-Type" content="text/html; charset=euc-kr">
<script language="javascript">
<!--
var oTbl;
//Row Ãß°¡
function insRow() {
  oTbl = document.getElementById("addTable");
  var oRow = oTbl.insertRow();
  oRow.onmouseover=function(){oTbl.clickedRowIndex=this.rowIndex}; //clickedRowIndex - Ŭ¸¯ÇÑ RowÀÇ À§Ä¡¸¦ È®ÀÎ;
  var oCell = oRow.insertCell();

  //»ðÀ﵃ Form Tag
  var frmTag = "<input type=text name=addText[] style=width:350px; height:20px;> ";
  frmTag += "<input type=button value='»èÁ¦' onClick='removeRow()' style='cursor:hand'>";
  oCell.innerHTML = frmTag;
}
//Row »èÁ¦
function removeRow() {
  oTbl.deleteRow(oTbl.clickedRowIndex);
}

function frmCheck()
{
  var frm = document.form;
  
  for( var i = 0; i <= frm.elements.length - 1; i++ ){
     if( frm.elements[i].name == "addText[]" )
     {
         if( !frm.elements[i].value ){
             alert("ÅؽºÆ®¹Ú½º¿¡ °ªÀ» ÀÔ·ÂÇϼ¼¿ä!");
             frm.elements[i].focus();
             return;
          }
      }
   }
}
//-->
</script>
</head>
<body>
<form name="form" method="post">
<table width="400" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td colspan="2" align="left" bgcolor="#FFFFFF">
      <table width="100%" border="0" cellpadding="0" cellspacing="0">
        <tr>
         <td colspan="5" bgcolor="#FFFFFF" height="25" align="left"><input name="addButton" type="button" style="cursor:hand" onClick="insRow()" value="Ãß°¡">
         <font color="#FF0000">*</font>Ãß°¡¹öÆ°À» Ŭ¸¯ÇØ º¸¼¼¿ä.</td>
        </tr>
        <tr>
         <td height="25">
          <table id="addTable" width="400" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF" border="0">
            <tr>
              <td><input type="text" name="addText[]" style="width:350px; height:20px;"></td>
              <td align="left"></td>
            </tr>
          </table></td>
        </tr>
       </table>
      </td>
   </tr>
</table>
<table width="400" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td height="10">
    </td>
    </tr>
    <tr>
    <td align="center">
    <input type="button" name="button" value="È®ÀÎ" onClick="frmCheck();">
    </td>
   </tr>
</table>
</form>
</body>
</html>
ÃßõÃßõ : 446 Ãßõ ¸ñ·Ï
¹øÈ£ Á¦¸ñ
73
PHP ¸ÞÀÏ(mail) ÇÔ¼ö¸¦ ÀÌ¿ëÇÑ Ã·ºÎÈ­ÀÏ Àü¼ÛÇϱâ
72
PHP ÇÔ¼ö °£´Ü Á¤¸®
71
PHP¿¡¼­ ¼¼¼Ç(session) »ç¿ëÇϱâ
70
PHP explode ÇÔ¼ö¸¦ ÀÌ¿ëÇÑ ¹®ÀÚ¿­ ºÐ¸®
69
PHP split ÇÔ¼ö¸¦ ÀÌ¿ëÇÑ ¹®ÀÚ¿­ ºÐ¸®
PHP À̸§ÀÌ °°Àº Æûű×(Form Tag)ÀÇ °ª(value) ó¸®Çϱâ
67
PHP ¿À´Ã³¯Â¥¸¦ ±âÁØÀ¸·Î ÀÌÀü,ÀÌÈÄ ³¯Â¥±¸Çϱâ
66
PHP ÇÑ±Û ¹®ÀÚ¿­ ÀÚ¸£±â
65
PHP ¹öÀü È®ÀÎÇϱâ
64
PHP - SELECT·Î ¹ÝȯµÈ ·¹ÄÚµå °¹¼ö¿Í Ä÷³ÀÇ °¹¼ö¸¦ ¾Ë·ÁÁÖ´Â ÇÔ¼ö
63
PHP Æû(form)°ªÀÇ À¯È¿¼º üũ
62
PHP no-cache ¼³Á¤(µÚ·Î°¡±â ¸·±â)
61
PHP ¿¡·¯ ó¸® ÇÔ¼ö die
60
PHP MySQL ¸í·É¾î ½ÇÇà ÇÔ¼ö mysql_query
59
PHP·Î MySQL µ¥ÀÌÅͺ£À̽º ¸¸µé±â(»ý¼ºÇϱâ)
58
PHP¿Í ÀÚ¹Ù½ºÅ©¸³Æ®¸¦ ÀÌ¿ëÇÑ µå·Ó´Ù¿î ¸Þ´º
57
PHP - xml ÀоîµéÀ̱â(read) Ŭ·¡½º
56
PHP ÆÄÀÏ ½Ã½ºÅÛ(File System) ´Ù·ç±â #1
55
PHP ÆÄÀÏ ³»¿ë Àбâ(freadÇÔ¼ö)
54
PHP ÆÄÀÏ ÇÑÁÙ Àбâ(fgetsÇÔ¼ö)
53
PHP ÇöÀç ÆäÀÌÁöÀÇ µµ¸ÞÀθíÀ̳ª urlµîÀÇ Á¤º¸ ¾Ë¾Æ¿À±â
52
PHP - À¥»çÀÌÆ®ÀÇ À¯È¿¼º üũ
51
fsockopen ÇÔ¼ö¸¦ ÀÌ¿ëÇؼ­ À¥»çÀÌÆ®¿¡ µ¥ÀÌÅÍ Àü¼ÛÇϱâ
50
PHP - ÆÄÀÏ´Ù¿î·Îµå ÇÔ¼ö
49
PHP ÆÄÀÏ 1¹ÙÀÌÆ®¾¿ Àбâ(fgetcÇÔ¼ö)
48
PHP °£´ÜÇÑ ÆÄÀÏ ¾÷·Îµå(upload) ¿¹Á¦
47
PHP ¹®ÀÚ¿­ÀÇ ±æÀ̸¦ °°°Ô ¸¸µé±â
46
PHP $HTTP_COOKIE_VARS·Î °ªÀÌ ¾È ³Ñ¾î¿Ã¶§
45
PHP ³­¼ö¸¦ ÀÌ¿ëÇÑ ÄíÆù¹øÈ£ »ý¼ºÇϱâ
44
PHP - POST ¹æ½ÄÀÇ ÆÄÀÏ ¾÷·Îµå ´Ù·ç±â
¸ñ·Ï
¹ÂÁ÷Æ®·ÎÆ® ºÎ»ê±¤¿ª½Ã ºÎ»êÁø±¸ °¡¾ßµ¿ ¤Ó °³ÀÎÁ¤º¸Ãë±Þ¹æħ
Copyright ¨Ï musictrot All rights reserved.