...

View Full Version : problem with <button> tag in mozilla



LottaLava
12-22-2003, 05:04 PM
Hello folks, i have just a simple page with a form and one <button> tag, this button has a alert( "hello world" ) in its onclick. You can see that after press that button and appear Hello World dialog, the page calls formīs submit. This happen with every button created with <button> tag, Mozilla understad this kind of button as a submit button. Can anyone tell me how would i avoid it?

Regards,
LottaLava

requestcode
12-22-2003, 05:26 PM
Can we see your code?

brothercake
12-22-2003, 05:28 PM
<button type="submit">..</button> should do it

LottaLava
12-23-2003, 12:16 PM
I donīt want its button to submit my page. To do that i created a method that check if userīs browser is Mozilla and change buttonīs property.

The code is pretty simple, checkout:

<html>
<head>
<script language="JavaScript">
function test( )
{
alert( "They are camming." );
}
</script>
</head>
<body>
<form name="frmMain"
method="POST"
action="http://localhost/blah">
<button name="btBlah" onClick="test( );">Test</button>
</form>
</body>
</html>

Kor
12-23-2003, 12:45 PM
Try the input tag...

<input type="button" value="Test" name="btBlah" onClick="test( );">

Choopernickel
12-23-2003, 02:26 PM
function test (text) {
alert(text);
return false;
}

...

<button onclick="return test('blah');">Button!</button>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum