Closed Bug 311319 Opened 19 years ago Closed 19 years ago

javascript submit() does not react if I add "return false" in such code '<button onclick="send(); return false;">

Categories

(Firefox :: General, defect)

x86
Windows 98
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 309348

People

(Reporter: krzydzie, Unassigned)

Details

User-Agent:       Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.8b4) Gecko/20050908 Firefox/1.4
Build Identifier: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.8b4) Gecko/20050908 Firefox/1.4  (1.5 Beta 1)

I have code:
<script language=javascript>
  function send(){
  document.doc.submit();
}
</script>
<form name=doc action="/test" method=post>
<button onclick="send(); return false;">send</button>
</form>

I want to myself influence on submiting page in function send so I set "return
false" in onclick, otherwise <button> itsel will submit page.
Unfortunately in Firefox 1.5B1 "document.doc.submit();" does not react in
presence of "return false"
There is not such problem in Firefox 1.0.7 or Internet Explorer

What more. In Firefox 1.5b1 I can set "return false" in "onclick" in "<input
type=submit onclick="send(); return false;">" and "<input type=button
onclick="send(); return false;">". In those cases "document.doc.submit()" react
very good.

Reproducible: Always

Steps to Reproduce:
Write down the code below. All buttons have "return false" in "onclick". Only
after "<button>" there is no reaction. In other you have "Welcome to..."

echo '
<script language=javascript>
  function send(){
  document.doc.submit();
}
</script>

<form name=doc action="/test" method=post>
  <button name=button onclick="send(); return false;">button</button>
&nbsp;&nbsp;&nbsp;
  <input type=submit name=in_submit value=in_submit onclick="send(); return
false;">&nbsp;&nbsp;
  <input type=button name=in_button value=in_button onclick="send(); return
false;">&nbsp;&nbsp;
  <input type=text name=field>
</form>
';

if(!empty($_POST['field'])) echo "Welcome to ".$_POST['field'];

Actual Results:  
I have not reaction after clicking on "button"

Expected Results:  
I should get "Welcome to.." after clicking "button"

*** This bug has been marked as a duplicate of 309348 ***
Status: UNCONFIRMED → RESOLVED
Closed: 19 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.