Blazer
Blazer

Reputation: 316

Submit form onload won't work

I need page to auto submit predefined word when page loads and post results.

<form id="search_form" action="http://mysite.com/search-results/" target="my-iframe" method="post"> 

<div class="field"><input type="text" value="Atlanta" class="dimmed" placeholder="City" name="City[all_words]" /></div>


  <input class="row_right" onclick="document.getElementById('search_form').submit()">

I tried this and didn't work

<body onload="submitform()"> 

this one too didn't work :

<script>document.getElementById('SearchForm').submit();</script>

Upvotes: 0

Views: 4377

Answers (1)

Cody Bonney
Cody Bonney

Reputation: 1658

It looks like you are calling the form element by the wrong id.

document.getElementById('search_form').submit();

Working example

Upvotes: 3

Related Questions