Skip to main content
Stack Overflow
  1. About
  2. For Teams

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Required fields*

Javascript Submit

Hi I have the following script in my form

function pdf() {
var frm = document.getElementById("form1");
frm.action = "http://www.abbysoft.co.uk/index.php";
frm.target="_blank"
frm.submit()
}

this is called from the following in my form <input class="buttn" type="button" value="Test" onclick="pdf()"

The code work up to the frm.submit() but it will not submit

Can anyone offer any advice please ?

Answer*

Draft saved
Draft discarded
Cancel
3
  • this is a better approach but Darin Dimitrov is right about the syntax error. Also he should just return true in pdf() instead of submiting and returning false shouldn't he? Commented Mar 28, 2010 at 13:23
  • Is he submiting the same form? Commented Mar 28, 2010 at 13:32
  • Its very difficult to tell what is actually being suggested here, but it looks like it boils down to "Use onsubmit instead of onclick" — that won't solve the problem, and likely wouldn't fit the situation which looks like wanting to submit to a different address if a particular button is clicked. Commented Mar 28, 2010 at 13:43

lang-js

AltStyle によって変換されたページ (->オリジナル) /