473,471 Members | 1,964 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 2042
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.