English 中文(简体)
允许用户从<http://select>中选择无效
原标题:Allowing a user to select null from an html <select> drop down

我在我的网站上翻了一番选择箱子。 不需要这个领域。 如果用户意外地作出选择,是否容易让用户重新确定外地无效?

我认为,第一个选择是“请选择......”,然后看用户是否选择了这一选择,并确定相应的价值为无效。 这只是感到 kind。

最佳回答

this example will make the user able to reset the select without seeing the "null" option. http://jsbin.com/ojozar/2

  <select id="select">
    <option value="1" >option 1</option>
    <option value="2" >option 2</option>
    <option value="3" >option 3</option>
  </select>
  <input type="button" value="reset" id="resetbtn" />  

js:

  $( #resetbtn ).click(function(){
    $( select#select ).prepend( <option selected="selected" value="null" class="null"></option> );        
  });

  $( select#select ).bind( focus click mouseup ,function(){
    $(this).find( option.null ).remove();
  });
问题回答

暂无回答




相关问题
Instead of NULL, should I write `0x0` or `0`?

I know that you are supposed to use 0 instead of NULL in c++ (even though NULL is defined as 0 in C++ most of the time). Recently I came across some code where 0x0 was used instead, though. What is ...

SELECT the newest record with a non null value in one column

I have table data which looks like this id | keyword | count | date 1 | ipod | 200 | 2009-08-02 2 | ipod | 250 | 2009-09-01 3 | ipod | 150 | 2009-09-04 4 | ipod | NULL | 2009-09-07 Now what I am ...

C#: Range intersection when endpoints are null (infinity)

Ok, I have these intersection methods to work with ranges, and they work well as long as the range endpoints are not null: public static bool Intersects<T>(this Range<T> first, Range<T&...

How can I store NULLs in NOT NULL field?

I just came across NULL values in NOT-NULL fields in our test database. How could they get there? I know that NOT-NULL constraints can be altered with NOVALIDATE clause, but that would change table s ...

热门标签