我想要在控制台中执行这段代码,我想要做的是更改一些字段的值并继续提交。
var animal = new Array(); //Declare Array 
animal[0] = 'cat';
animal[1] = 'dog';
animal[2] = 'cow';
animal[3] = 'snake';
animal[4] = 'goat';
animal[5] = 'tiger';
animal[6] = 'lion';
animal[7] = 'horse';
var createFunc = function(i){
    return function(){
        var token_field = document.getElementById('animal_name'); 
        token_field.value = animal[i]; //Change the value of the field with each array value
        var path_field = document.getElementById('To_do');
        path_field.value='feed'; // Change the other field with 'feed'
        var submit_all = document.getElementById('graph_submit');
        submit_all.click(); //submit the form
    };
};
for (var i = 0; token.length > i; i++) {
    setTimeout(createFunc(i), 2000);
}但当单击按钮时,页面会重新加载并中断循环……因此,只有第一个值被提交,其他值保留。
第一次提交(超过2秒)后,提交页面的代码停止执行。由于POST查询,页面将被重新加载。但是我想要提交所有的值,但是页面被重新加载。
我能做些什么呢?
发布于 2014-02-19 14:43:23
单击“graph_submit”作用域时,有可能发生更改,循环中断。
您可以在此处使用防止默认功能。
https://stackoverflow.com/questions/21872870
复制相似问题