define the submit button

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • reneecccwest

    #1

    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.testf orm.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="JavaS cript">
    <!--
    function submitForm(){
    if (document.testf orm.leveltype.v alue != "" &&
    document.testfo rm.officename.v alue != "") {
    document.testfo rm.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="officenam e" value="" />

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

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

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

    </form>


    </body>
    </html>
  • Thomas 'PointedEars' Lahn

    #2
    Re: define the submit button

    reneecccwest wrote:
    [color=blue]
    > 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.testf orm.submit();" in the javascript, but I
    > don't think it is right.[/color]

    Correct. Submit will be impossible without JavaScript then, aside from
    the fact that you never know what is considered the default submit button.
    [color=blue]
    > [...]
    > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">[/color]

    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)
    [color=blue]
    > <html>
    > <head>
    > <title>Untitled </title>[/color]

    I hope this is different in the real document.
    [color=blue]
    > </head>
    >
    > <body>
    > <script language="JavaS cript">[/color]

    This should read

    <script type="text/javascript">
    [color=blue]
    > <!--
    > function submitForm(){[/color]

    function submitForm(o)
    {
    var result = false;
    [color=blue]
    > if (document.testf orm.leveltype.v alue != "" &&
    > document.testfo rm.officename.v alue != "") {
    > document.testfo rm.submit();
    > }
    > else {
    > alert("Please select level and/or office before pressing the
    > button");
    > }[/color]

    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;
    [color=blue]
    > }[/color]
    [color=blue]
    > //-->
    > </script>[/color]

    You better place the script in the "head" element.
    [color=blue]
    > <form name="testform" method="post" action="test02. cfm">[/color]

    <form
    action="test02. cfm"
    method="post"
    onsubmit="retur n submitForm(this )">
    [color=blue]
    > <input type="text" name="leveltype " value="" />
    >
    > <input type="text" name="officenam e" value="" />
    >
    > <input type="Button" name="levelbtn" value="Filter"
    > onclick="submit Form()" />
    >
    > <input type="submit" name="innerbtn" value="inner" />
    >
    > <input type="submit" name="outerbtn" value="outer" />[/color]

    This is not XHTML, and there are default values for
    some attributes, so you can safely omit them.

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


    HTH

    PointedEars

    Comment

    Working...