开发者

Javascript injection

I would like to fill out and a submit a form explicitly with JavaScript. First, I thought I had to use window.open but it's certainly wrong because if it gets loaded, the left of my scripts writt开发者_开发技巧en for example in a html file would be ignored.

Do I have to create a .js file and fire that one?


uhhhh...not exactly sure how this relates to injections...you can do this with jQuery in a handful of lines of code.

say you have the following form:

<form id="theForm" name="testForm" action="whatever.php" method="get">
    <input type="text" name="cow" />
    <input type="text" name="sheep" />
    <input type="text" name="pig" />
    <input type="submit" value="Submit" />
</form>

If you have jQuery loaded, all you need to do is this:

function submitForm(){
var cowVal="Cows go moooo!";
var sheepVal="Sheep go baaaaaaah!";
var pigVal="pigs go sooooeeeeeeeh!";
$("#theForm input").eq(0).val(cowVal).next().val(sheepVal).next().val(pigVal).parent().submit();
}

Hope that helps!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜