0

I am trying to take radio and checkbox values from an HTML form, and save/export/pass the values to an external javascript file where the TaffyDB structured database is initialized.

HTML:

            <strong> <font color="black">Color</strong></font>
            <form name="colorForm">
                <input type="checkbox" name="color" value="Red">
                <font color="black">Red
                    <br>
                </font>
                <input type="checkbox" name="color" value="Orange">
                <font color="black">Orange
                    <br>
                </font>
                <input type="checkbox" name="color" value="Yellow">
                <font color="black">Yellow
                    <br>

                <!--function to return checkbox values for colors-->
                <script type="text/javascript">
                    function get_color() {
                        //console.log(document.colorForm);
                        for (var i = 0; i < document.colorForm.length; i++) {
                            while (document.colorForm[i].checked && i < document.colorForm.length) {
                                var check_color = document.colorForm[i].value;
                                return check_color;
                                colorList.insert({color:get_color});
                            }//end of while
                        }//end of for
                    }//end of get_color
                </script>

JavaScript:

var colorList = TAFFY();

4

1 回答 1

0

您在插入数据库之前返回 check_color。

return 语句结束一个函数,你不能在它之后执行代码。

尝试将您的退货声明放在其他地方。

于 2016-09-09T06:18:33.187 回答