views:

47

answers:

1

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 written for example in a html file would be ignored.

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

A: 

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 if="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 moo!";
var sheepVal="Sheep go baaaaah!";
var pigVal="pigs go sooooeeeeeh!";
$("#theForm input").eq(0).val(cowVal).next().val(sheepVal).next().val(pigVal).parent().submit();
}

Hope that helps!

Trafalmadorian