简体   繁体   English

删除 select 列表中的向下箭头

[英]delete down-arrow in select list

<select name="TESTFORM" disabled="disabled">
    <option>one</option>
    <option>two</option>
    <option>three</option>
    <option>four</option>
</select>

how can i disable drop-down list and send data or completely delete down-arrow?如何禁用下拉列表并发送数据或完全删除向下箭头? if i add disable="disabled" then i have blocked select list, but data TESTFORM dont send with form.如果我添加 disable="disabled" 那么我已经阻止了 select 列表,但数据 TESTFORM 不与表单一起发送。 Maybe in css?也许在 css 中? I select list with JavaScript.我列出了 select 和 JavaScript。

Disabled fields are not submitted.不提交禁用的字段。 So you have two solutions:所以你有两个解决方案:

Enable the form field when the form's submit event is triggered and disable it again a moment later:当表单的submit事件被触发时启用表单字段并稍后再次禁用它:

$('#yourform').submit(function() {
    $('select[name="TESTFORM"]', this).prop('disabled', false);
    window.setTimeout(function() {
        $('select[name="TESTFORM"]', this).prop('disabled', true);
    }, 100)
});

The other solution would be adding an <input type="hidden"> to actually send the information:另一种解决方案是添加一个<input type="hidden">来实际发送信息:

var val = $('#yourform select[name="TESTFORM"]').val();
$('<input/>', { type: 'hidden', 'name': 'TESTFORM' }).val(val).appendTo('#yourform');

As far as I know you can't "delete" the down arrow, and the post by ThiefMaster is backwards.据我所知,您不能“删除”向下箭头,并且 ThiefMaster 的帖子是倒退的。 What you'd want to do is enable that select list onsubmit of the form which would allow the value to be sent.您想要做的是启用 select 列表 onsubmit 允许发送值的表单。 If you're not using ajax to submit the form you don't need to worry about re-disabling it afterwards because the page will be reloaded and the select disabled again.如果您不使用 ajax 提交表单,则无需担心之后重新禁用它,因为页面将重新加载并且 select 再次禁用。

$('#yourform').submit(function() {
    $('select[name="TESTFORM"]', this).prop('disabled', false);
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM