Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
543 views
in Technique[技术] by (71.8m points)

javascript - 我需要什么CSS来编码切换按钮? [关闭](What CSS do I need to code a toggle button? [closed])

I have made a form, and i want to have it so the toggle button that controls the submit button.

(我已经制作了一个表单,我想拥有它,以便控制提交按钮的切换按钮。)

  • If the Toggle Button is off then the "submit" button is disabled and show a warning message.

    (如果切换按钮处于关闭状态,则“提交”按钮将被禁用并显示警告消息。)

  • If the Toggle Button is on then the "submit" button is enabled.

    (如果切换按钮处于打开状态,则启用“提交”按钮。)

I have VB code that may work.

(我有可能有效的VB代码。)

I just need to convert it somehow, but don't know how.

(我只需要以某种方式进行转换,但是不知道如何进行转换。)

Public Class Form1
Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox1.CheckedChanged
    If CheckBox1.Checked = True Then
        Button1.Enabled = True
    End If
    If CheckBox1.Checked = False Then
        Button1.Enabled = False
    End If
End Sub

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    If Me.Enabled = True Then
        Button1.Enabled = False
    End If
End Sub
End Class

This is a Windows VB Form that I made.

(这是我制作的Windows VB表单。)

I want to convert this code to a online page form based CSS code.

(我想将此代码转换为基于CSS的在线页面表单。)

Is this possible?

(这可能吗?)

Sadly I don't know how to use CSS to code this.

(可悲的是,我不知道如何使用CSS编写代码。)

  ask by GlitchingGang translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I've written a code below to help you.

(我在下面编写了代码来帮助您。)

I suggest you check this link before asking your next questions.

(建议您在询问下一个问题之前先检查链接。)

Here is example, http://jsfiddle.net/os6a075y/

(这是示例, http://jsfiddle.net/os6a075y/)

Html

(HTML)

<form> 
    <div class="checkbox">
        <label>
            <input type="checkbox" id="openCloseCheckbox" data-toggle="toggle" checked="checked" />
            Open Close Button
        </label>
    </div>
   <br/>
   <br/>
    <div>
        <input type="submit" id="submitButton" class="btn btn-default"/>
    </div>
</form>

JS/JQUERY

(JS / JQUERY)

$("#openCloseCheckbox").change(function() {
    if(!this.checked) {
        $('#submitButton').attr("disabled","disabled");
    }else
    {
        $('#submitButton').removeAttr("disabled","disabled");
    }
});

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...