Web Analytics Made Easy -
StatCounter Java question - CodingForum

Announcement

Collapse
No announcement yet.

Java question

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Java question

    I have completed my coding and i am trying to make my submit button a validating button as well as my link to my thank you page any advice

  • #2
    Usually, it makes more sense to put your validation on the <FORM>.

    As in:
    Code:
    <form action="...." method="..." onsubmit="return validateForm(this);">
    You do that so that if the form can be submitted by hitting the enter key the validation is still executed. If you put it *only* on the submit button, then hitting enter will not trigger the call to the validator.

    As to "advice": What kind of advice??? You mean "what kind of validation should I perform?" or "how do I do validation?" or what??
    Be yourself. No one else is as qualified.

    Comment


    • #3
      question on java

      below is my code I am trying to get my (submit)button to link to another page as well as validate the site page as well. Any help PLEASE
      [code]
      <script type="text/javascript" src="basicValidation.js"></script>
      <head>
      <title>Kudler Fine Foods</title>
      <p><img src="Kudler.gif"</p>
      <font size="3" face="Arial" color="#0000FF">
      <body>
      <form onSubmit="return checkrequired(this)">

      <tr>
      <td>Last Name:</td><td><input type="text" name=" required last name "></td>
      </tr>
      <tr>
      <td>First Name:</td><td><input type="text" name="required first name "></td>
      </tr><BR>
      <tr>
      <td>Address:</td><td><input type="text" name="required Address "></td>
      </tr>
      <td>City:</td><td><input type="text" name="required City "></td>
      </tr>
      <tr>
      <font color="blue">State</font>
      <form name="theForm"> <tt>
      <select name="aaa" size="1">
      <option selected value="/index.php">Alabama </option>
      <option selected value="/index.php">Alaska </option>
      <option selected value="/index.php">Arizona </option>
      <option selected value="/index.php">Arkansas </option>
      <option selected value="/index.php">California</option>
      <option selected value="/index.php">Colorado</option>
      <option selected value="/index.php">Connecticut</option>
      <option selected value="/index.php">Delawara</option>
      <option selected value="/index.php">Florida</option>
      <option selected value="/index.php">Georgia </option>
      <option selected value="/index.php">Hawaii </option>
      <option selected value="/index.php">Idaho</option>
      <option selected value="/index.php">Illinois </option>
      <option selected value="/index.php">Indiana </option>
      <option selected value="/index.php">Iowa</option>
      <option selected value="/index.php">Kansas</option>
      <option selected value="/index.php">Kentucky </option>
      <option selected value="/index.php">Louisiana </option>
      <option selected value="/index.php">Maine</option>
      <option selected value="/index.php">Maryland</option>
      <option selected value="/index.php">Massachusetts </option>
      <option selected value="/index.php">Michagan </option>
      <option selected value="/index.php">Minnesota</option>
      <option selected value="/index.php">Mississippi</option>
      <option selected value="/index.php">Missouri </option>
      <option selected value="/index.php">Montana</option>
      <option selected value="/index.php">Nebraska </option>
      <option selected value="/index.php">Nevada </option>
      <option selected value="/index.php">New Hampshire </option>
      <option selected value="/index.php">New Jersey </option>
      <option selected value="/index.php">New Mexico</option>
      <option selected value="/index.php">New York</option>
      <option selected value="/index.php">North Carolina</option>
      <option selected value="/index.php">North Dakota</option>
      <option selected value="/index.php">Ohio</option>
      <option selected value="/index.php">Oklahoma </option>
      <option selected value="/index.php">Oregon </option>
      <option selected value="/index.php">Pennsylvania</option>
      <option selected value="/index.php">Rhode Island </option>
      <option selected value="/index.php">South Carolina </option>
      <option selected value="/index.php">South Dakota</option>
      <option selected value="/index.php">Tennessee</option>
      <option selected value="/index.php">Texas </option>
      <option selected value="/index.php">Utah </option>
      <option selected value="/index.php">Vermont</option>
      <option selected value="/index.php">Virginia</option>
      <option selected value="/index.php">Washington </option>
      <option selected value="/index.php">West Virginia </option>
      <option selected value="/index.php">Wisconsin</option>
      <option selected value="/index.php">Wyoming</option>
      </form>
      <tr><BR>
      <tr>
      <td>Zip:</td><td><input type="text" name="required Zip "></td>
      </tr><BR>
      <tr>
      <td>E-mail:</td><td><input type="text" name="requiredemail"><td>
      </tr>
      <tr>
      <td>Phone Number:</td><td><input type="text" name="required Phone Number"><td>
      </tr><br>
      <input type=submit value="Submit">
      <input type=reset value="Reset">
      </form>
      </body>
      <font size="3" face="Arial" color="#0000FF">
      <BODY>
      <font color="red">
      NOTE:
      Before submitting the form, please check for accuracy and to ensure that all fields are filled in as appropriate to your request, and as

      required.<BR>
      If you have problems in submitting this form, please report the to Kudler Fine Foods at (858) 555-0138.
      </font>
      </body>

      <style type ="text/css" media="all">
      body{
      button {
      color: Yellow;
      background-color:#F7FE2E;
      border: Pink outset thick;
      margin-right: .5em;
      text-align: center;
      font-weight: bold;
      font-size: 12pt;
      font-family: arial,helvetica,sans-serif; }
      </p>

      <p><a href="#top">Back To Top<a/></p>

      [code]

      Comment


      • #4
        To link to another page, you just put the URL into the ACTION="..." of the <FORM>:

        <form action="anotherPage.html" onSubmit="return checkrequired(this)">

        Presto, done.

        As for the validation: How can we tell? You are hiding the code to that in your "basicValidation.js" file, which we can't see.
        Be yourself. No one else is as qualified.

        Comment


        • #5
          java

          No that is not the page that I am trying to link to. I am trying to link to a Thank you for your submission

          Comment


          • #6
            But you have TWO FATAL FLAWS, that I see.

            (1) You have *TWO* <form> tags. No. ONE <FORM> ONLY! (Some advanced users can find reasons for multiple <form>s, but trust me, this page is NOT one that needs or wants more than one.) Get rid of that second <form>. If you think you need a name for the form, consolidate all the info into the one tag.

            <form name = "theForm" action="someotherpage.html" onSubmit="return checkrequired(this)">

            ******

            (2) Your <select> with all those states makes NO SENSE at all!

            As coded, NO MATTER WHAT STATE the user selects, the page that this <form> is submitted to will see "/index.php" as the value of the select!

            On top of that, it's only legit to have *ONE* <option> marked as "selected" (unless you are using a <select multiple>, which wouldn't make sense for a state chooser).

            Also, why would you give the name "aaa" to a <select> that allows the choice of a state???

            I don't know what the page you are going to submit to is looking for.

            If it's looking for a full state NAME, then just omit the value= from all the <option>s, thus:
            Code:
            <select name="state">
            <option> Alabama </option>
            <option>Alaska </option>
            <option>Arizona </option>
            ... etc. ...
            If the next page is expecting a conventional two letter state abbreviation, then use THOSE for the value=, thus:
            Code:
            <select name="state">
            <option value="AL"> Alabama </option>
            <option value="AK">Alaska </option>
            <option value="AZ">Arizona </option>
            ... etc. ...
            SO...I don't think the page is quite ready for prime time yet, regardless of the validation issues.

            What page *ARE* you submitting this <form> to??? Is it a PHP page???
            Be yourself. No one else is as qualified.

            Comment


            • #7
              No that is not the page that I am trying to link to. I am trying to link to a Thank you for your submission
              ROTFL! THAT WAS JUST AN EXAMPLE!

              You don't really think that somebody would have a page named anotherPage.html, do you?

              BUT...

              But what's the point of having the form and validating it if you then don't DO anything with the information in the form????

              If all you do is go to a page that says "thank you" and nothing else, what was the point in collecting the info in the first place???
              Be yourself. No one else is as qualified.

              Comment


              • #8
                java

                No to just another html here is the other page trying to make these two connect as well as valadiate
                [code]
                <html>

                <head>

                <title>acknowledgement page</title>
                </head>

                <body>

                <h3>Your information has been submitted</h3>
                <h3> We at Kudler Fine Foods what to say thank you for your business<h3>

                </body>
                <style type ="text/css" media="all">
                body{
                button {
                color: Yellow;
                background-color: yellow;
                border: Pink outset thick;
                margin-right: .5em;
                text-align: center;
                font-weight: bold;
                font-size: 12pt;
                font-family: arial,helvetica,sans-serif; }
                </html>

                [code]

                Comment


                • #9
                  Your persistently refer to Java. It has already been explained to you that Java and Javascript are entirely different programming languages, in spite of the confusingly similar names. You seem to have completely ignored this and other advice you were given in
                  http://www.codingforum.net/showthread.php?t=163179
                  Post #4.

                  This does not augur well for a successful career in programming.

                  The redirect to a "Thank You" page after a successful submission is carried out by the server-side formmail script you are using (we assume - or is this another example of making an *** of u and me?).

                  e.g: <input type="hidden" name="redirect" value="http://yourWebSite.com/thankyou.html">
                  Last edited by Philip M; Apr 8, 2009, 02:54 AM.

                  All the code given in this post has been tested and is intended to address the question asked.
                  Unless stated otherwise it is not just a demonstration.

                  Comment


                  • #10
                    Ahhh... I didn't have the "history" that you have, Philip!

                    In this thread, he doesn't show any "formmail" page as the action= of his <FORM> and he doesn't show that hidden field.

                    Seems to have really gotten off on the wrong foot. The <SELECT> with all the <option value="/index.php"> indicates that he hasn't yet mastered HTML, so no wonder he has problems with the JavaScript.

                    And you have to wonder about "basicValidation.js" -- does that file really exist or is he just plopping it onto the page and HOPING it will be there and work???

                    Mark: I hope you will take this kindly, but I think we both agree you need to go back to square one and learn how all the various "pieces" fit together. I would guess that you have skipped a couple of lectures and/or reading assignments.
                    Last edited by Old Pedant; Apr 8, 2009, 03:43 AM.
                    Be yourself. No one else is as qualified.

                    Comment


                    • #11
                      Javascript

                      This is a java script. I am in the beginning classes. this is the first one for this sort of stuff. all that I do have is reading my books. that is why i am taking in all that is told to me. i am trying to just get the (submit ) button to valadate and give me a thank you for your reply.

                      Comment


                      • #12
                        Originally posted by markwaterman View Post
                        This is a java script. I am in the beginning classes. this is the first one for this sort of stuff. all that I do have is reading my books. that is why i am taking in all that is told to me. i am trying to just get the (submit ) button to valadate and give me a thank you for your reply.
                        No, it is not. Java Script == Script, written in Java. JavaScript (one word) is a programming language. As to being in the beginning classes... errr, are you sure? Now, I'm not an expert, seeing I haven't had any formal education in regards to coding, (Except for Pascal, though that doesn't apply here) but form validation isn't really something I would give to someone at a beginner level. Though judging by the HTML you're showing... I guess you should be in the beginner classes... being that you have two body tags, most of your tags are not closed and so on and so forth. All in all, as this is clearly a homework assignment, don't expect us to do it for you. You will not learn anything from it and I doubt your teacher won't realize. (Not to mention that we had a case of a teacher visiting these exact forums and ending up seeing one of his students' assignments on here and asking one of us to come to class and explain some of the code.) Post your code... hopefully your own work... and if it has issues, ask for advice, you will get that much... something along the lines of: "Hey, look at this line, the problem is coming from there... as a hint, you can't florbit the grommit and expect it to gromble" Although I'm not sure that would work for you either... I see plenty of people offering advice and giving suggestions... and in the end you end up posting that "it's not what you're trying to do" or something along those lines. Give it some serious thought, sit down, do some reading... do some research... as Philip has stated in your previous thread, the issue of form validation has been chewed through a few billion times on this forum already, look one of those examples up and try to modify it to suit you. In addition, I don't see the contents of your external JavaScript file posted anywhere... and supposedly, that is the file that does contain your validate function... If the problem is with it... why haven't you posted it?
                        Last edited by Eldarrion; Apr 8, 2009, 05:58 PM.
                        The way to success is to assume that there are no impossible things. After all, if you think something is impossible, you will not even try to do it.

                        How to ask smart questions?

                        Comment


                        • #13
                          Listen i am not asking for you to give me anything and I do not remember anywhere in my statement asking for a smart butt. so like the saying goes nothing nice then shut the heck up. how is that for coding. I am trying to learn here that is all no do it for me just here is where you should start at.

                          Comment


                          • #14
                            Well, you seem to refuse to help us help you. Several times you have been asked to SHOW the javascript code that is supposed to do the validation and you have yet to do so.

                            Further, you have yet to fix your HTML so that, if and when you did show us the JavaScript code, your form might have a prayer of actually doing something. We do have to wonder why you are tackling JavaScript when you don't seem to understand HTML, yet. We could be wrong about that, but the HTML code you have shown so far is simply too badly broken to even worry about the JavaScript aspects.

                            Again, I'm afraid the opinion here is unanimous (among those who have tried to help) that you aren't listening to us and you aren't learning from what any of us are saying. If we are wrong, then prove us wrong.

                            But if you persist in just saying "no" instead of showing us what we ask for and making suggested changes, there seems like there is nothing anybody will be able to do to help you.
                            Be yourself. No one else is as qualified.

                            Comment


                            • #15
                              Code:
                              var rude;
                              var thanks;
                              if (rude && !thanks) {
                              var interestLost = true;
                              var moreHelp = 0;
                              }

                              All the code given in this post has been tested and is intended to address the question asked.
                              Unless stated otherwise it is not just a demonstration.

                              Comment

                              Working...
                              X