admin管理员组文章数量:1323330
I have parsed a page using curl and it contains some check box and a 'select all' and a 'submit' button . Clicking the button selects every check box.'select all' button triggers a javascript function which actually select all check box.
Now i need to click 'select all' and 'submit' button.How can I do this ??
Here is the button code:
input type="button" onclick="SelectAll(137)" value="Select All"
Here is the js function:
function SelectAll(n)
{
for(i=0;i<n;i++)
document.getElementById("ch"+i).checked=true;
}
I have parsed a page using curl and it contains some check box and a 'select all' and a 'submit' button . Clicking the button selects every check box.'select all' button triggers a javascript function which actually select all check box.
Now i need to click 'select all' and 'submit' button.How can I do this ??
Here is the button code:
input type="button" onclick="SelectAll(137)" value="Select All"
Here is the js function:
function SelectAll(n)
{
for(i=0;i<n;i++)
document.getElementById("ch"+i).checked=true;
}
Share
Improve this question
edited Jul 20, 2014 at 6:49
Quazi Marufur Rahman
asked Jun 7, 2012 at 18:25
Quazi Marufur RahmanQuazi Marufur Rahman
2,6235 gold badges35 silver badges51 bronze badges
3
-
1
Was I the only one to notice the
curl
reference in the question? Nobody else wonder if the select all + submit need to be done usingcurl
? – Alexander Commented Jun 7, 2012 at 18:32 - "I have parsed a page using curl" What do you mean parsed, is it [the content] actually loaded in a browser? – epascarello Commented Jun 7, 2012 at 18:39
- yes...all chekboxes and buttons are loaded in a browser – Quazi Marufur Rahman Commented Jun 7, 2012 at 18:44
2 Answers
Reset to default 5You can't. If you must use cURL, you'd have to manually craft the POST request yourself. This would involve finding the names of all the checkboxes and sending a bunch of checkbox1=on&checkbox2=on&...
in the POST body. See http://davidwalsh.name/execute-http-post-php-curl for a general example of a POST request through cURL with PHP.
Another option would be to use something like Selenium Web Driver, which pretty much allows you to script a web browser like Firefox that can run JavaScript, click things, etc.
Pass a parameter in with your Curl request that gets parsed by jQuery on its $(document).ready(). There's some plugins that help with parsing parameters.
Something like
$(document).ready(function(){
var buttonPress = $.param("buttonPress");
if (buttonPress == true)
$("#myButton").click();
});
本文标签: phpjavascript button click using curlStack Overflow
版权声明:本文标题:php - javascript button click using curl - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742136553a2422395.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论