推荐答案 Marcelo写道: Marcelo wrote: 我需要制作一个机器人填写表格。我已经用php 网站做了这个,但现在我需要在一个javascript页面网站(机器人可以是php,asp,asp.net),任何人都知道我该怎么办?或者某个地方我可以找到更多信息吗? 谢谢! Marcelo Hi, I need to make a robot that fills forms. I already made that with php sites, but now I need that in a javascript pages site ( the robot can be php,asp, asp.net ), anyone knows how can I do it? or somewhere I can find more info? Thanks! Marcelo 你好, 你想要一个填写表单的JS脚本吗? JS必须与表单在同一页面上,否则你可能会遇到进入 安全问题。 (如果你想在另一个窗口填写表格。) 如果打开在同一页面上,只需填写您想要的内容: < form action =" bal.php" name =" myForm"> firstname:< input type =" text"名称= QUOT;姓名" value =""> < br> lastname:< input type =" text"名称= QUOT;姓" value =""> < br> < input type =" submit" value =" send"> < / form> < script type =" text / javascript"> //填写它 document.forms [" myForm"]。firstname.value =" Zaphod"; document.forms [" myForm" ;]。lastname.value =" Beeblebrox"; //发送它 document.forms [" myForm"]。submit(); < / script> 这就是你要找的东西吗? 问候, Erwin Moller Hi, Do you want a JS script that fills in a form? JS must be on the same page as the form, or you might hit intosecurity-issues.(If you want to fill a form on another window.) If it is on the same page, just fill in what you want like this: <form action="bal.php" name="myForm">firstname: <input type="text" name="firstname" value=""><br>lastname: <input type="text" name="lastname" value=""><br><input type="submit" value="send"></form> <script type="text/javascript">// fill itdocument.forms["myForm"].firstname.value = "Zaphod";document.forms["myForm"].lastname.value = "Beeblebrox";// send itdocument.forms["myForm"].submit();</script>Is that what you are looking for? Regards,Erwin Moller 感谢您的回答。 我想要php填充一个javascript表单,但我不知道如何发送 值或选择组合框的值(在某些情况下)。 Best问候 Marcelo Hi, Thanks for the answer. I want that php fills a javascript form, but I don''t know how to sendthe values or select the values of combo boxes ( in some cases ). Best Regards Marcelo Marceloaécrit:Marcelo a écrit : 我希望php填写一个javascript表单,但我不知道如何发送 t他重视或选择组合框的值(在某些情况下)。 I want that php fills a javascript form, but I don''t know how to send the values or select the values of combo boxes ( in some cases ). 通常一个表格是用html编写的。 JS中的脚本只是帮助用户填写字段(*) php中的脚本可以预先填写字段或/并显示必要的选项 选择 Php知道如何接收字段或组合框值, 在JavaScript中无需发送那些。 从php重新发布表单,php填写它知道的字段。 (*)JS查看字段是否填满,如果没有,则阻止提交 < form onsubmit = return validate(this) blah ...> 函数验证(aForm){ for(var i = 0; i< aForm.length; i ++){ if(aform [i] .type ==''text''&& aForm [i] .value ==''''){ alert(txt + aForm [i] .name); aForm [i] .focus(); aForm [i] .select(); 返回false; } if(aform [i] .type ==''select''&& aForm [i] .value =='' ''){ alert(''请在列表中选择:''+ aForm [i] .name); aForm [i] .focus(); aForm [i] .select(); 返回false; } if(aform [i] .type ==''radio''){ var e = aForm.elements [aForm [i] .name]; if(e.length> 0) { var ok = true; for(var j = 0; j< e.length; j ++)if(e。[j] .checked)ok = false ; if(ok){ alert(''请选择:''+ aForm [i] .name); aForm [ i] [0] .focus(); 返回false; } } } } 返回true; } - Stephane Moriaux et son [moins] vieux Mac Usually a form is written and works in html.Scripts in JS are only to help in filling fields by users(*)Scripts in php can pre-fill fields or/and display necessary options ofselects Php knows how to receive fields or combo boxes values,there is nothing to do in JavaScript to send those.On re-issue of form from php, the php fills fields it knows. (*) JS looks if fields are filled up and, if not, prevent submit<form onsubmit="return validate(this)" blah ...> function validate(aForm) {for (var i=0;i<aForm.length;i++) {if(aform[i].type == ''text'' && aForm[i].value == '''') {alert(txt+aForm[i].name);aForm[i].focus();aForm[i].select();return false;}if(aform[i].type == ''select'' && aForm[i].value == '''') {alert(''Please choice in list : ''+aForm[i].name);aForm[i].focus();aForm[i].select();return false;}if(aform[i].type == ''radio'') {var e = aForm.elements[aForm[i].name];if(e.length>0) {var ok = true;for(var j=0;j<e.length;j++) if(e.[j].checked) ok=false;if(ok) {alert(''Please choice : ''+aForm[i].name);aForm[i][0].focus();return false;}}}}return true;} --Stephane Moriaux et son [moins] vieux Mac 这篇关于机器人javascript帮助!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-21 18:36