开发者

dropdown menu html form personalized category

开发者 https://www.devze.com 2023-04-02 00:49 出处:网络
i have the following part of code of a dropdown menu <p> <label for=\'Select a Category \'>Select a Category<font color=\"red\"><strong>*</strong></font>: </la

i have the following part of code of a dropdown menu

<p>
<label for='Select a Category '>Select a Category<font color="red"><strong>*</strong></font>: </label></p> 
<p><div id='contactform_category_errorloc' class='err'></div>

  <select name="category" class="input">
    <option value="0" selected="selected">
      [choose yours]
    </opti开发者_如何转开发on>
    <option value="Arts and entertainment">Arts and entertainment</option>
    <option value="Automotive">Automotive</option>
    <option value="Business">Business</option>
    <option value="Computers">Computers</option>
    <option value="Games">Games</option>
    <option value="Health">Health</option>
    <option value="Internet">Internet</option>
    <option value="News and Media">News and Media</option>
    <option value="Recreation">Recreation</option>
    <option value="Reference">Reference</option>
    <option value="Shopping">Shopping</option>
    <option value="Sports">Sports</option>
    <option value="World">World</option>
  </select>
</p>

i want add in drop down menu an option with value: "custom" that when i select this option appear just below a field blank as input text where i can add my personalized text so i can insert personalized category it's possible?


maybe you mean something like this: http://jsbin.com/ubihuw/edit#javascript,html so in php or something you can check then the "my_own_text" field ... dont know what you will exactly do ;)

js:

$('.input').change(function()
{
  if($(this).attr('value') == "0") {
    $('#choose_own_text').append('<input type="text" id="my_own_text" name="my_own_text" value="Please type in .." />');
  } else {
    $('#choose_own_text').empty();
  }
});

your code ...

<p><div id='contactform_category_errorloc' class='err'></div>

  <select name="category" class="input">
    <option value="0" selected="selected">
      [choose yours]
    </option>
    <option value="Arts and entertainment">Arts and entertainment</option>
    <option value="Automotive">Automotive</option>
    <option value="Business">Business</option>
    <option value="Computers">Computers</option>
    <option value="Games">Games</option>
    <option value="Health">Health</option>
    <option value="Internet">Internet</option>
    <option value="News and Media">News and Media</option>
    <option value="Recreation">Recreation</option>
    <option value="Reference">Reference</option>
    <option value="Shopping">Shopping</option>
    <option value="Sports">Sports</option>
    <option value="World">World</option>
  </select>
  <div id="choose_own_text"></div>
</p>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号