´ç½Å¿¡°Ô·Î ¶°³ª´Â ²Þ¼Ó¿©Çà - ²Þ¼Ó³ª¶ó(http://www.inyourdream.net) ÀÔ±¹Çϱâ | ¿µÁÖ±Ç ½Åû
  • ¸öºÎ¸² °ñ¶ó°ñ¶ó
  • ¼Ò±Ù¼Ò±Ù
  • µµ¶õµµ¶õ
  • ³«¼­¸¶´ç
  • Âø°¢ÇѾÆÀÌ
  • ¼ýÀÚ¸ÂÃß±â
  • ¼Ò¿øºô±â
  • ÈçÀû³²±â±â
  • ²Þ¼Ó¿©Çà
  • Ä£±¸Áý ³î·¯°¡±â
  • ¸ðµÎµå¸²´ÔÀÇ È¨
  • î¤éÞ´ÔÀÇ È¨
  • Çö¿ì´ÔÀÇ È¨
  • º°¾ÆÇØ´ÔÀÇ È¨
  • ÇÞ»ì´ÔÀÇ È¨
  • À̳ª´Ï´ÔÀÇ È¨
  • À¯¸®¾Ë´ÔÀÇ È¨
  • ³È³ÈÀÌ´ÔÀÇ È¨
  • ²ÀÁö´ÔÀÇ È¨
  • ´ë¼º´ÔÀÇ È¨
  • î¤éÞ / 2016-10-14 / ¿ÀÈÄ 1:30:08 / 61.78.108.65
    Á¶È¸¼ö : 506
    [̵̧] multiple selectbox
    <ul>
    <li onclick="this.parentNode.removeChild(this);">
    <input type="hidden" name="ingredients[]" value="Cheese" />
    Cheese
    </li>
    <li onclick="this.parentNode.removeChild(this);">
    <input type="hidden" name="ingredients[]" value="Ham" />
    Ham
    </li>
    <li onclick="this.parentNode.removeChild(this);">
    <input type="hidden" name="ingredients[]" value="Mushrooms" />
    Mushrooms
    </li>
    </ul>
    <select onchange="selectIngredient(this);">
    <option value="Cheese">Cheese</option>
    <option value="Olives">Olives</option>
    <option value="Pepperoni">Pepperoni</option>
    ...
    </select>

    function selectIngredient(select)
    {
    var option = select.options[select.selectedIndex];
    var ul = select.parentNode.getElementsByTagName('ul')[0];

    var choices = ul.getElementsByTagName('input');
    for (var i = 0; i < choices.length; i++)
    if (choices[i].value == option.value)
    return;

    var li = document.createElement('li');
    var input = document.createElement('input');
    var text = document.createTextNode(option.firstChild.data);

    input.type = 'hidden';
    input.name = 'ingredients[]';
    input.value = option.value;

    li.appendChild(input);
    li.appendChild(text);
    li.setAttribute('onclick', 'this.parentNode.removeChild(this);');

    ul.appendChild(li);
    }
     
    ¢º °ü·Ã ½ÎÀÌÆ®
  • http://odyniec.net/articles/multiple-select-fields/
  • Byte * 200 Byte À̳»·Î ÀÔ·ÂÇϼ¼¿ä À̸§ : Æнº¿öµå :