472,354 Members | 1,451 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,354 software developers and data experts.

define the submit button

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
1 1961
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Matt | last post by:
I want to understand the difference between submit button and regular button: <input type="submit"> and <input type="button">. My understanding is that submit button will send the entire HTML form...
2
by: jb | last post by:
Hello, I need to know which button was pressed in the submit , i tried reading the vaule of submit it the validateDate function but it returns 'undefined' value ; I do this in asp all the time, Not...
15
by: Mattia | last post by:
Hi! I have a <form> that can be submitted thruogh three buttons and I need to tell witch one was pressed when the form was submitted. I now do it with 3 <input type="submit" name="..."...
15
by: M Smith | last post by:
I have a form I want to submit to itself. I want to be able to type in a list of numbers and submit the form and have that list show up on the same form under the text box I typed them into and...
3
by: Adam | last post by:
Hey guys, I've decided to stop banging my head against the wall and just ask you guys for the answer. I can't seem to find it. I have a form in which I have multiple submit buttons; only, I'm...
5
by: rjames.clarke | last post by:
I have the following. $result=mysql_query($sql); $nrows=mysql_num_rows($result); for ($i=0;$i<$nrows;$i++) { $row_array=mysql_fetch_row($result); echo "<form name='testform'...
4
by: Dmitry Korolyov [MVP] | last post by:
When we use btnSubmit.Attributes = "javascript: this.disabled=true;" to make the button disabled and prevent users from clicking it again while form data still posting, there is no longer...
3
by: Jeff | last post by:
I have a payment form with a submit button. A large percentage of users double-click the submit button thus submitting their payment information twice. I would like to use javascript to disable...
4
by: j1dopeman | last post by:
Hi, I'd like to use a button to save and then submit a form. I can set the onlick of the button to mahButton_click or submit, but I can't figure out how to do both. It looks like c# can't...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it so the python app could use a http request to get...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.