By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,569 Members | 1,394 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,569 IT Pros & Developers. It's quick & easy.

define the submit button

P: n/a
Hello, I'd like to pass the "levelbtn" value when I click the filter
button, but there are also other submit form buttons.

I defined as "document.testform.submit();" in the javascript, but I
don't think it is right.

-----------------------------------------------

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Untitled</title>
</head>

<body>
<script language="JavaScript">
<!--
function submitForm(){
if (document.testform.leveltype.value != "" &&
document.testform.officename.value != "") {
document.testform.submit();
}
else {
alert("Please select level and/or office before pressing the
button");
}
}
//-->
</script>

<form name="testform" method="post" action="test02.cfm">

<input type="text" name="leveltype" value="" />

<input type="text" name="officename" value="" />

<input type="Button" name="levelbtn" value="Filter"
onclick="submitForm()" />

<input type="submit" name="innerbtn" value="inner" />

<input type="submit" name="outerbtn" value="outer" />

</form>
</body>
</html>
Jul 23 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
reneecccwest wrote:
Hello, I'd like to pass the "levelbtn" value when I click the filter
button, but there are also other submit form buttons.

I defined as "document.testform.submit();" in the javascript, but I
don't think it is right.
Correct. Submit will be impossible without JavaScript then, aside from
the fact that you never know what is considered the default submit button.
[...]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
There is the URL of the DTD (the system identifier) missing before
it is Valid HTML. The W3C Markup Validator is misguiding here as
it uses an Open Catalog for mapping DOCTYPE declarations to files.
(See comp.infosystem.www.authoring.misc)
<html>
<head>
<title>Untitled</title>
I hope this is different in the real document.
</head>

<body>
<script language="JavaScript">
This should read

<script type="text/javascript">
<!--
function submitForm(){
function submitForm(o)
{
var result = false;
if (document.testform.leveltype.value != "" &&
document.testform.officename.value != "") {
document.testform.submit();
}
else {
alert("Please select level and/or office before pressing the
button");
}
var e = o && o.elements;
if (e)
{
if (e['leveltype'].value != ""
&& e['officename'].value != "")
{
result = true;
}
else
{
alert(
"Please select level and/or office before pressing the button");
}
}

return result;
} //-->
</script>
You better place the script in the "head" element.
<form name="testform" method="post" action="test02.cfm">
<form
action="test02.cfm"
method="post"
onsubmit="return submitForm(this)">
<input type="text" name="leveltype" value="" />

<input type="text" name="officename" value="" />

<input type="Button" name="levelbtn" value="Filter"
onclick="submitForm()" />

<input type="submit" name="innerbtn" value="inner" />

<input type="submit" name="outerbtn" value="outer" />
This is not XHTML, and there are default values for
some attributes, so you can safely omit them.

<input name="leveltype">
<input name="officename">
<input type="submit" name="levelbtn" value="Filter">
<input type="submit" name="innerbtn" value="inner">
<input type="submit" name="outerbtn" value="outer">
</form>
[...]

HTH

PointedEars
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.