我有一个开关切换,其中包含以下代码,遵循我类似地执行的StackOverflow问题之一
<label class="switch">
<input type="checkbox" id="togBtn" value="false" name="disableYXLogo">
<div class="slider round"></div>
</label>
Run Code Online (Sandbox Code Playgroud)
在CSS中我禁用输入复选框
.switch input {display:none;}
那么我将如何获取该开关切换按钮的真/假值。我尝试了这个,但是对我不起作用
$("#togBtn").on('change', function() {
if ($(this).is(':checked')) {
$(this).attr('value', 'true');
}
else {
$(this).attr('value', 'false');
}});
Run Code Online (Sandbox Code Playgroud)
如何获取切换开关按钮的js中的check / uncheck或true / false值
我必须在table现有client_id列中插入一些数据,所以我使用 select 和 insert
INSERT into 'my_table' (column1, client_id, column3) VALUES (val1,select distinct client_id from 'my_table', val3)
我需要来自同一个表的my_tableclient_id 并且我需要在插入语句中使用 client_ids。
SELECT DISTINCT client_id FROM my_table 给了我 113 个 client_id,所以我想使用上述方法为每个 113 个客户端插入一些行。
我做了这个查询
INSERT INTO client_notification_preferences (client_id, object_type , frequency,created_at,updated_at) SELECT DISTINCT client_id, 'ClientShipment',1, CURRENT_TIMESTAMP , CURRENT_TIMESTAMP FROM client_notification_preferences;
create_table "client_notification_preferences", id: :uuid, default: "uuid_generate_v4()", force: :cascade do |t|
t.uuid "client_id"
t.string "object_type"
t.integer "frequency"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
Run Code Online (Sandbox Code Playgroud)
结尾