如何不断检查表单中的更改

问题描述 投票:-1回答:1

我需要一个代码,当表单中的某些信息发生变化时,例如文本字段中的文本,该按钮会将按钮的颜色更改为灰色(一旦它接收到单击时为绿色)。这将通知用户再次单击该按钮。

我已经尝试了一些代码,但没有成功

这是页面的链接:http://100awesomecraft.com/commands/creations/colored-chest.html

<form id="form">
    <div class="column100 trans t-center" style="font-size:0;">
        <div class="column20 trans t-center">
        </div>
        <div class="column60 trans t-center">
            <div class="column60 trans t-center" style="font-size:0;">
                <div class="column60 trans t-center">
                    Block
                    <input name="block" type="text" style="width:90%;" placeholder='stone'>
                </div>
                <div class="column10 trans t-center"><br>
                    :
                </div>
                <div class="column20 trans t-center">
                    Type
                    <input name="type" type="text" style="width:50%;" placeholder='0'>
                </div>
            </div>
            <br><br>
            <div class="column50 trans t-center" style="font-size:0;">
                <div class="column33 trans t-center">
                    1.11<br>
                    <div class="pretty p-svg p-curve p-pulse" style="margin:auto;margin-top:10px;font-size:50px;">
                        <input type="radio" id="1.11" name="radio">

                        <div class="state p-success">
                            <svg class="svg svg-icon" viewBox="0 0 20 20">
                                <path d="M7.629,14.566c0.125,0.125,0.291,0.188,0.456,0.188c0.164,0,0.329-0.062,0.456-0.188l8.219-8.221c0.252-0.252,0.252-0.659,0-0.911c-0.252-0.252-0.659-0.252-0.911,0l-7.764,7.763L4.152,9.267c-0.252-0.251-0.66-0.251-0.911,0c-0.252,0.252-0.252,0.66,0,0.911L7.629,14.566z"
                                      style="stroke: white;fill:white;"></path>
                            </svg>
                            <label></label>
                        </div>
                    </div>
                </div>
                <div class="column33 trans t-center">
                    1.12<br>
                    <div class="pretty p-svg p-curve p-pulse" style="margin:auto;margin-top:10px;font-size:50px;">
                        <input type="radio" id="1.12" name="radio">

                        <div class="state p-success">
                            <svg class="svg svg-icon" viewBox="0 0 20 20">
                                <path d="M7.629,14.566c0.125,0.125,0.291,0.188,0.456,0.188c0.164,0,0.329-0.062,0.456-0.188l8.219-8.221c0.252-0.252,0.252-0.659,0-0.911c-0.252-0.252-0.659-0.252-0.911,0l-7.764,7.763L4.152,9.267c-0.252-0.251-0.66-0.251-0.911,0c-0.252,0.252-0.252,0.66,0,0.911L7.629,14.566z"
                                      style="stroke: white;fill:white;"></path>
                            </svg>
                            <label></label>
                        </div>
                    </div>
                </div>
            </div>
            <br><br>
            Essentials installed?<br>
            <div class="pretty p-svg p-curve p-pulse" style="margin:auto;margin-top:10px;font-size:50px;">
                <input id="essentials" type="checkbox"/>
                <div class="state p-success">
                    <!-- svg path -->
                    <svg class="svg svg-icon" viewBox="0 0 20 20">
                        <path d="M7.629,14.566c0.125,0.125,0.291,0.188,0.456,0.188c0.164,0,0.329-0.062,0.456-0.188l8.219-8.221c0.252-0.252,0.252-0.659,0-0.911c-0.252-0.252-0.659-0.252-0.911,0l-7.764,7.763L4.152,9.267c-0.252-0.251-0.66-0.251-0.911,0c-0.252,0.252-0.252,0.66,0,0.911L7.629,14.566z"
                              style="stroke: white;fill:white;"></path>
                    </svg>
                    <label></label>
                </div>
            </div>
            <br><br>
            Add glow<br>
            <div class="pretty p-svg p-curve p-pulse" style="margin:auto;margin-top:10px;font-size:50px;">
                <input id="glow" type="checkbox"/>
                <div class="state p-success">
                    <!-- svg path -->
                    <svg class="svg svg-icon" viewBox="0 0 20 20">
                        <path d="M7.629,14.566c0.125,0.125,0.291,0.188,0.456,0.188c0.164,0,0.329-0.062,0.456-0.188l8.219-8.221c0.252-0.252,0.252-0.659,0-0.911c-0.252-0.252-0.659-0.252-0.911,0l-7.764,7.763L4.152,9.267c-0.252-0.251-0.66-0.251-0.911,0c-0.252,0.252-0.252,0.66,0,0.911L7.629,14.566z"
                              style="stroke: white;fill:white;"></path>
                    </svg>
                    <label></label>
                </div>
            </div>
        </div>
        <div class="column20 trans t-center">
        </div>
    </div>
</form><br>
<button id="submit" class="button" onclick="command()">Submit & Copy</button><br><br>
<script>
    document.getElementById('submit').onclick = command;
    function command() {
        if (document.getElementById('essentials').checked) {
            initiation = "/minecraft:";
        } else {
            initiation = "/";
        }
        if (document.getElementById('glow').checked) {
            glow = "glowstone";
        } else {
            glow = "glass";
        }
        var x = document.getElementById("form");
        var type = x.elements["type"].value;
        var block = x.elements["block"].value;
        if (block == "") {
            block = "stone";
        }
        if (type == "") {
            type = "0";
        }
        if (document.getElementById('1.11').checked) {
            var command = `/summon falling_block ~ ~1 ~ { Block:command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/fill ~1 ~-1 ~1 ~-1 ~53 ~-1 air" } ,Passengers:[{ id:falling_block,Block:command_block,Data:1,Time:1,TileEntityData:{ auto:0,Command:"/fill ~1 ~ ~1 ~-1 ~53 ~-1 air" } ,Passengers:[{ id:falling_block,Block:repeating_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~0.063 ~-1.9981 ~0.063 /summon armor_stand ~ ~ ~ {Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, ArmorItems:[{},{},{},{id:\\"stone\\",Damage:0s,Count:1b}],HandItems:[{},{}],CustomName:\\"Chest\\",DisabledSlots:2039583}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~-0.063 ~-1.9982 ~-0.063 /summon armor_stand ~ ~ ~ {Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, ArmorItems:[{},{},{},{id:\\"stone\\",Damage:0s,Count:1b}],HandItems:[{},{}],CustomName:\\"Chest\\",DisabledSlots:2039583}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~0.063 ~-1.9983 ~-0.063 /summon armor_stand ~ ~ ~ {Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, ArmorItems:[{},{},{},{id:\\"stone\\",Damage:0s,Count:1b}],HandItems:[{},{}],CustomName:\\"Chest\\",DisabledSlots:2039583}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~-0.063 ~-1.9984 ~0.063 /summon armor_stand ~ ~ ~ {Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, ArmorItems:[{},{},{},{id:\\"stone\\",Damage:0s,Count:1b}],HandItems:[{},{}],CustomName:\\"Chest\\",DisabledSlots:2039583}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~ ~-1.998 ~ /summon armor_stand ~ ~ ~ {Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, ArmorItems:[{},{},{},{id:\\"stone\\",Damage:0s,Count:1b}],HandItems:[{},{}],CustomName:\\"Chest\\",DisabledSlots:2039583}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~0.3 ~-0.579 ~-0.06 /summon armor_stand ~ ~ ~ {Small:1b,Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Rotation:[135f],ArmorItems:[{},{},{},{}],HandItems:[{id:\\"stone\\",Damage:0s,Count:1b},{}],CustomName:\\"Chest\\",DisabledSlots:2039583,Pose:{RightArm:[345f,0f,0f]}}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~0.113 ~-0.579 ~-0.06 /summon armor_stand ~ ~ ~ {Small:1b,Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Rotation:[135f],ArmorItems:[{},{},{},{}],HandItems:[{id:\\"stone\\",Damage:0s,Count:1b},{}],CustomName:\\"Chest\\",DisabledSlots:2039583,Pose:{RightArm:[345f,0f,0f]}}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~-0.074 ~-0.579 ~-0.06 /summon armor_stand ~ ~ ~ {Small:1b,Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Rotation:[135f],ArmorItems:[{},{},{},{}],HandItems:[{id:\\"stone\\",Damage:0s,Count:1b},{}],CustomName:\\"Chest\\",DisabledSlots:2039583,Pose:{RightArm:[345f,0f,0f]}}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~-0.261 ~-0.579 ~-0.06 /summon armor_stand ~ ~ ~ {Small:1b,Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Rotation:[135f],ArmorItems:[{},{},{},{}],HandItems:[{id:\\"stone\\",Damage:0s,Count:1b},{}],CustomName:\\"Chest\\",DisabledSlots:2039583,Pose:{RightArm:[345f,0f,0f]}}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~0.261 ~-0.579 ~0.06 /summon armor_stand ~ ~ ~ {Small:1b,Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Rotation:[315f],ArmorItems:[{},{},{},{}],HandItems:[{id:\\"stone\\",Damage:0s,Count:1b},{}],CustomName:\\"Chest\\",DisabledSlots:2039583,Pose:{RightArm:[345f,0f,0f]}}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~0.074 ~-0.579 ~0.06 /summon armor_stand ~ ~ ~ {Small:1b,Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Rotation:[315f],ArmorItems:[{},{},{},{}],HandItems:[{id:\\"stone\\",Damage:0s,Count:1b},{}],CustomName:\\"Chest\\",DisabledSlots:2039583,Pose:{RightArm:[345f,0f,0f]}}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~-0.113 ~-0.579 ~0.06 /summon armor_stand ~ ~ ~ {Small:1b,Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Rotation:[315f],ArmorItems:[{},{},{},{}],HandItems:[{id:\\"stone\\",Damage:0s,Count:1b},{}],CustomName:\\"Chest\\",DisabledSlots:2039583,Pose:{RightArm:[345f,0f,0f]}}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~-0.3 ~-0.579 ~0.06 /summon armor_stand ~ ~ ~ {Small:1b,Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Rotation:[315f],ArmorItems:[{},{},{},{}],HandItems:[{id:\\"stone\\",Damage:0s,Count:1b},{}],CustomName:\\"Chest\\",DisabledSlots:2039583,Pose:{RightArm:[345f,0f,0f]}}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~-0.059 ~-0.579 ~-0.302 /summon armor_stand ~ ~ ~ {Small:1b,Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Rotation:[45f],ArmorItems:[{},{},{},{}],HandItems:[{id:\\"stone\\",Damage:0s,Count:1b},{}],CustomName:\\"Chest\\",DisabledSlots:2039583,Pose:{RightArm:[345f,0f,0f]}}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~-0.059 ~-0.579 ~-0.115 /summon armor_stand ~ ~ ~ {Small:1b,Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Rotation:[45f],ArmorItems:[{},{},{},{}],HandItems:[{id:\\"stone\\",Damage:0s,Count:1b},{}],CustomName:\\"Chest\\",DisabledSlots:2039583,Pose:{RightArm:[345f,0f,0f]}}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~-0.059 ~-0.579 ~0.072 /summon armor_stand ~ ~ ~ {Small:1b,Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Rotation:[45f],ArmorItems:[{},{},{},{}],HandItems:[{id:\\"stone\\",Damage:0s,Count:1b},{}],CustomName:\\"Chest\\",DisabledSlots:2039583,Pose:{RightArm:[345f,0f,0f]}}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~-0.059 ~-0.579 ~0.259 /summon armor_stand ~ ~ ~ {Small:1b,Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Rotation:[45f],ArmorItems:[{},{},{},{}],HandItems:[{id:\\"stone\\",Damage:0s,Count:1b},{}],CustomName:\\"Chest\\",DisabledSlots:2039583,Pose:{RightArm:[345f,0f,0f]}}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~0.060 ~-0.579 ~-0.260 /summon armor_stand ~ ~ ~ {Small:1b,Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Rotation:[225f],ArmorItems:[{},{},{},{}],HandItems:[{id:\\"stone\\",Damage:0s,Count:1b},{}],CustomName:\\"Chest\\",DisabledSlots:2039583,Pose:{RightArm:[345f,0f,0f]}}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~0.060 ~-0.579 ~-0.073 /summon armor_stand ~ ~ ~ {Small:1b,Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Rotation:[225f],ArmorItems:[{},{},{},{}],HandItems:[{id:\\"stone\\",Damage:0s,Count:1b},{}],CustomName:\\"Chest\\",DisabledSlots:2039583,Pose:{RightArm:[345f,0f,0f]}}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~0.060 ~-0.579 ~0.114 /summon armor_stand ~ ~ ~ {Small:1b,Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Rotation:[225f],ArmorItems:[{},{},{},{}],HandItems:[{id:\\"stone\\",Damage:0s,Count:1b},{}],CustomName:\\"Chest\\",DisabledSlots:2039583,Pose:{RightArm:[345f,0f,0f]}}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~0.060 ~-0.579 ~0.301 /summon armor_stand ~ ~ ~ {Small:1b,Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Rotation:[225f],ArmorItems:[{},{},{},{}],HandItems:[{id:\\"stone\\",Damage:0s,Count:1b},{}],CustomName:\\"Chest\\",DisabledSlots:2039583,Pose:{RightArm:[345f,0f,0f]}}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~0.2203 ~-1.495 ~0.156 /summon armor_stand ~ ~ ~ {Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Small:1b,ArmorItems:[{},{},{},{id:\\"stone\\",Damage:0s,Count:1b}],HandItems:[{},{}],CustomName:\\"Chest\\",DisabledSlots:2039583}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~0.2206 ~-1.495 ~-0.156 /summon armor_stand ~ ~ ~ {Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Small:1b,ArmorItems:[{},{},{},{id:\\"stone\\",Damage:0s,Count:1b}],HandItems:[{},{}],CustomName:\\"Chest\\",DisabledSlots:2039583}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~0.2209 ~-1.432 ~0.155 /summon armor_stand ~ ~ ~ {Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Small:1b,ArmorItems:[{},{},{},{id:\\"stone\\",Damage:0s,Count:1b}],HandItems:[{},{}],CustomName:\\"Chest\\",DisabledSlots:2039583}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~0.2212 ~-1.432 ~-0.156 /summon armor_stand ~ ~ ~ {Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Small:1b,ArmorItems:[{},{},{},{id:\\"stone\\",Damage:0s,Count:1b}],HandItems:[{},{}],CustomName:\\"Chest\\",DisabledSlots:2039583}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~-0.156 ~-1.495 ~0.2203 /summon armor_stand ~ ~ ~ {Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Rotation:[90f],Small:1b,ArmorItems:[{},{},{},{id:\\"stone\\",Damage:0s,Count:1b}],HandItems:[{},{}],CustomName:\\"Chest\\",DisabledSlots:2039583}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~0.155 ~-1.495 ~0.2206 /summon armor_stand ~ ~ ~ {Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Rotation:[90f],Small:1b,ArmorItems:[{},{},{},{id:\\"stone\\",Damage:0s,Count:1b}],HandItems:[{},{}],CustomName:\\"Chest\\",DisabledSlots:2039583}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~-0.156 ~-1.432 ~0.2209 /summon armor_stand ~ ~ ~ {Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Rotation:[90f],Small:1b,ArmorItems:[{},{},{},{id:\\"stone\\",Damage:0s,Count:1b}],HandItems:[{},{}],CustomName:\\"Chest\\",DisabledSlots:2039583}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~0.155 ~-1.432 ~0.2212 /summon armor_stand ~ ~ ~ {Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Rotation:[90f],Small:1b,ArmorItems:[{},{},{},{id:\\"stone\\",Damage:0s,Count:1b}],HandItems:[{},{}],CustomName:\\"Chest\\",DisabledSlots:2039583}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~-0.2203 ~-1.495 ~-0.156 /summon armor_stand ~ ~ ~ {Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Rotation:[180f],Small:1b,ArmorItems:[{},{},{},{id:\\"stone\\",Damage:0s,Count:1b}],HandItems:[{},{}],CustomName:\\"Chest\\",DisabledSlots:2039583}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~-0.2206 ~-1.495 ~0.155 /summon armor_stand ~ ~ ~ {Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Rotation:[180f],Small:1b,ArmorItems:[{},{},{},{id:\\"stone\\",Damage:0s,Count:1b}],HandItems:[{},{}],CustomName:\\"Chest\\",DisabledSlots:2039583}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~-0.2209 ~-1.432 ~-0.156 /summon armor_stand ~ ~ ~ {Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Rotation:[180f],Small:1b,ArmorItems:[{},{},{},{id:\\"stone\\",Damage:0s,Count:1b}],HandItems:[{},{}],CustomName:\\"Chest\\",DisabledSlots:2039583}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~-0.2212 ~-1.432 ~0.155 /summon armor_stand ~ ~ ~ {Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Rotation:[180f],Small:1b,ArmorItems:[{},{},{},{id:\\"stone\\",Damage:0s,Count:1b}],HandItems:[{},{}],CustomName:\\"Chest\\",DisabledSlots:2039583}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~-0.156 ~-1.495 ~-0.2206 /summon armor_stand ~ ~ ~ {Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Rotation:[270f],Small:1b,ArmorItems:[{},{},{},{id:\\"stone\\",Damage:0s,Count:1b}],HandItems:[{},{}],CustomName:\\"Chest\\",DisabledSlots:2039583}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~0.155 ~-1.495 ~-0.2203 /summon armor_stand ~ ~ ~ {Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Rotation:[270f],Small:1b,ArmorItems:[{},{},{},{id:\\"stone\\",Damage:0s,Count:1b}],HandItems:[{},{}],CustomName:\\"Chest\\",DisabledSlots:2039583}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~-0.156 ~-1.432 ~-0.2212 /summon armor_stand ~ ~ ~ {Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Rotation:[270f],Small:1b,ArmorItems:[{},{},{},{id:\\"stone\\",Damage:0s,Count:1b}],HandItems:[{},{}],CustomName:\\"Chest\\",DisabledSlots:2039583}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~0.155 ~-1.432 ~-0.2209 /summon armor_stand ~ ~ ~ {Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Rotation:[270f],Small:1b,ArmorItems:[{},{},{},{id:\\"stone\\",Damage:0s,Count:1b}],HandItems:[{},{}],CustomName:\\"Chest\\",DisabledSlots:2039583}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~ ~-1 ~ /setblock ~ ~ ~ glowstone 0" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~0.1881 ~-2.8751 ~0.1881 /summon armor_stand ~ ~ ~ {Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, ArmorItems:[{},{},{},{id:\\"stone\\",Damage:0s,Count:1b}],HandItems:[{},{}],CustomName:\\"Chest\\",DisabledSlots:2039583}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~-0.1883 ~-2.8753 ~-0.1883 /summon armor_stand ~ ~ ~ {Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, ArmorItems:[{},{},{},{id:\\"stone\\",Damage:0s,Count:1b}],HandItems:[{},{}],CustomName:\\"Chest\\",DisabledSlots:2039583}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~-0.1885 ~-2.8755 ~0.1885 /summon armor_stand ~ ~ ~ {Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, ArmorItems:[{},{},{},{id:\\"stone\\",Damage:0s,Count:1b}],HandItems:[{},{}],CustomName:\\"Chest\\",DisabledSlots:2039583}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~0.1887 ~-2.8757 ~-0.1887 /summon armor_stand ~ ~ ~ {Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, ArmorItems:[{},{},{},{id:\\"stone\\",Damage:0s,Count:1b}],HandItems:[{},{}],CustomName:\\"Chest\\",DisabledSlots:2039583}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/minecraft:tp @e[type=Creeper,name=Chest] ~ -100 ~" } ,Passengers:[{ id:falling_block,Block:repeating_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Remove] ~ ~ ~ /minecraft:kill @e[type=armor_stand,r=3,name=Chest]" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/minecraft:tp @e[type=Creeper,name=Remove] ~ -100 ~" } ,Passengers:[{ id:falling_block,Block:command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/give @p minecraft:spawn_egg 1 51 {HideFlags:33,display:{Name:\\"Create Chest\\"},ench:[{id:1,lvl:0}],EntityTag:{id:minecraft:creeper,CustomName:\\"Chest\\", ActiveEffects:[{Id:14,Amplifier:0,Duration:100,ShowParticles:0b}]}}" } ,Passengers:[{ id:falling_block,Block:command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/give @p minecraft:spawn_egg 1 51 {HideFlags:33,display:{Name:\\"Remove Chest\\"},ench:[{id:1,lvl:0}],EntityTag:{id:minecraft:creeper,CustomName:\\"Remove\\", ActiveEffects:[{Id:14,Amplifier:0,Duration:100,ShowParticles:0b}]}}"}}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}`;
        }
        if (document.getElementById('1.12').checked) {
            var command = `/summon falling_block ~ ~1 ~ { Block:command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/fill ~1 ~-1 ~1 ~-1 ~53 ~-1 air" } ,Passengers:[{ id:falling_block,Block:command_block,Data:1,Time:1,TileEntityData:{ auto:0,Command:"/fill ~1 ~ ~1 ~-1 ~53 ~-1 air" } ,Passengers:[{ id:falling_block,Block:repeating_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~0.063 ~-1.9981 ~0.063 /summon armor_stand ~ ~ ~ {Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, ArmorItems:[{},{},{},{id:\\"stone\\",Damage:0s,Count:1b}],HandItems:[{},{}],CustomName:\\"Chest\\",DisabledSlots:2039583}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~-0.063 ~-1.9982 ~-0.063 /summon armor_stand ~ ~ ~ {Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, ArmorItems:[{},{},{},{id:\\"stone\\",Damage:0s,Count:1b}],HandItems:[{},{}],CustomName:\\"Chest\\",DisabledSlots:2039583}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~0.063 ~-1.9983 ~-0.063 /summon armor_stand ~ ~ ~ {Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, ArmorItems:[{},{},{},{id:\\"stone\\",Damage:0s,Count:1b}],HandItems:[{},{}],CustomName:\\"Chest\\",DisabledSlots:2039583}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~-0.063 ~-1.9984 ~0.063 /summon armor_stand ~ ~ ~ {Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, ArmorItems:[{},{},{},{id:\\"stone\ock,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~ ~-1.998 ~ /summon armor_stand ~ ~ ~ {Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, ArmorItems:[{},{},{},{id:\\"stone\\",Damage:0s,Count:1b}],HandItems:[{},{}],CustomName:\\"Chest\\",DisabledSlots:2039583}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~0.3 ~-0.579 ~-0.06 /summon armor_stand ~ ~ ~ {Small:1b,Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Rotation:[135f],ArmorItems:[{},{},{},{}],HandItems:[{id:\\"stone\\",Damage:0s,Count:1b},{}],CustomName:\\"Chest\\",DisabledSlots:2039583,Pose:{RightArm:[345f,0f,0f]}}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~0.113 ~-0.579 ~-0.06 /summon armor_stand ~ ~ ~ {Small:1b,Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Rotation:[135f],ArmorItems:[{},{},{},{}],HandItems:[{id:\\"stone\\",Damage:0s,Count:1b},[{Id:14,Amplifier:0,Duration:100,ShowParticles:0b}]}}"}}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}`;
        }

        var replace_block = '"stone';
        var replace_type = 'Damage:0s';
        var replace_initiation = "/minecraft:";
        var replace_glowstone = "glowstone";
        var filter1 = new RegExp(replace_block, 'g');
        var filter2 = new RegExp(replace_type, 'g');
        var filter3 = new RegExp(replace_glowstone, 'g');
        var filter4 = new RegExp(replace_initiation, 'g');
        var result1 = command.replace(filter1, '"' + block);
        var result2 = result1.replace(filter2, 'Damage:' + type + 's');
        var result3 = result2.replace(filter3, glow);
        var result4 = result3.replace(filter4, initiation);
        var temp = document.createElement("textarea");
        document.body.appendChild(temp);
        temp.value = result4;
        temp.select();
        document.execCommand("copy");
        document.body.removeChild(temp);
        document.getElementById("submit").style.background = 'rgba(92,184,92,1)';
        var form = document.getElementById("form");
        form.addEventListener("input", function () {
            alert("changed!");
        });
    }
</script>
javascript forms
1个回答
1
投票

如果你想定位文本框更改你需要oninput="checkChange()"如果不是你可以只使用onchange="checkChange()"

var submitButton = document.getElementById('submit');
submitButton.onclick = command;

function command() {
   event.preventDefault();
   submitButton.style.background = 'rgba(92,184,92,1)';
}

function checkChange(){ 
//here you can do what you need, ex change the button color 
  submitButton.style.background = 'rgba(90,90,90,1.0)';
}
<form id="form" oninput="checkChange()" onchange="checkChange()">
  <input type="text" >
  <input type="radio">
  <button id="submit"> Submit </button>
</form>

如果你想通过JS添加事件处理程序,你应该将它们从你的函数命令中删除()

var submitButton = document.getElementById('submit');
submitButton.onclick = command;

function command() {
   event.preventDefault();
   submitButton.style.background = 'rgba(92,184,92,1)';
}

function checkChange(){ 
//here you can do what you need, ex change the button color 
  submitButton.style.background = 'rgba(90,90,90,1.0)';
}

var form = document.getElementById("form");
form.addEventListener("input", checkChange);
form.addEventListener("change", checkChange);
<form id="form">
  <input type="text" >
  <input type="radio">
  <button id="submit"> Submit </button>
</form>
© www.soinside.com 2019 - 2024. All rights reserved.