HTML forms and javascript

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • star111792
    New Member
    • Jan 2007
    • 26

    #1

    HTML forms and javascript

    hi,
    i have just started learning web development. i m trying to make a simple calender web application using HTML and JAVASCRIPT. i want that all months are displayed in a drop-down list. when user selects any month from this list and clicks the OK button, the calender of selected month should be displayed below that drop-down list. now my requirement is that i have to write code for calender table as well as the form code in Javascript. when i tried to use the form tag in script tag in header, it gave a run-time error. i dont know how to solve this problem. can anyone plz help me !!!!
  • star111792
    New Member
    • Jan 2007
    • 26

    #2
    HTML forms and javascript

    hi,
    i have just started learning web development. i m trying to make a simple calender web application using HTML and JAVASCRIPT. i want that all months are displayed in a drop-down list. when user selects any month from this list and clicks the OK button, the calender of selected month should be displayed below that drop-down list. now my requirement is that i have to write code for calender table as well as the form code in Javascript. when i tried to use the form tag in script tag in header, it gave a run-time error. i dont know how to solve this problem. can anyone plz help me !!!!

    Comment

    • r035198x
      MVP
      • Sep 2006
      • 13225

      #3
      Originally posted by star111792
      hi,
      i have just started learning web development. i m trying to make a simple calender web application using HTML and JAVASCRIPT. i want that all months are displayed in a drop-down list. when user selects any month from this list and clicks the OK button, the calender of selected month should be displayed below that drop-down list. now my requirement is that i have to write code for calender table as well as the form code in Javascript. when i tried to use the form tag in script tag in header, it gave a run-time error. i dont know how to solve this problem. can anyone plz help me !!!!
      What error did you get which code did you use?

      Comment

      • star111792
        New Member
        • Jan 2007
        • 26

        #4
        Originally posted by r035198x
        What error did you get which code did you use?

        i m presenting the entire code for ur kind consideration.




        [HTML] <html>

        <head>
        <meta http-equiv="Content-Language" content="sv">
        <meta name="GENERATOR " content="Micros oft FrontPage 5.0">
        <meta name="ProgId" content="FrontP age.Editor.Docu ment">
        <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
        <title>2007</title>

        <script language="javas cript">


        function abc()
        {
        document.write( '<form name=\"f1\" action=\"--WEBBOT-SELF--\" method=\"POST\" >');



        <!--webbot bot="SaveResult s" u-file="C:\Docume nts and Settings\Mahmoo d\Desktop\MONTH S\_private\form _results.csv" s-format="TEXT/CSV" s-label-fields="TRUE" --><p>&nbsp;&nbsp ;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp ;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp ;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp ;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp ;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp ;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp ;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp ;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp ;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp ;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp ;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp ;&nbsp;&nbsp;&n bsp; &nbsp;&nbsp;&nb sp;&nbsp;&nbsp; ";

        var a="<p align=center>";

        a+="<select size=1 name=\"D1\">";
        a+="<option selected value=1>January </option>";
        a+="<option value=2>Februar y</option>";
        a+="<option value=3>March</option>";
        a+="<option value=4>April</option>";
        a+="<option value=5>May</option>";
        a+="<option value=6>June</option>";
        a+="<option value=7>July</option>";
        a+="<option value=8>August</option>";
        a+="<option value=9>Septemb er</option>";
        a+="<option value=10>Octobe r</option>";
        a+="<option value=11>Novemb er</option>";
        a+="<option value=12>Decemb er</option>";
        a+="</select>&nbsp; <b><font size=4>2007&nbs p;&nbsp;&nbsp;& nbsp;&nbsp;&nbs p;";
        a+="<input type=button name=ok value=OK onClick=go()>";


        a+="</font></b>";

        a+="</p>";
        document.write( '</form>');

        document.write( a);

        }




        function go()
        {
        abc();

        if(f1.D1.value= =1)
        {

        var w="<table border=1 width=100%>";
        w+="<tr>";
        w+="<td width=12% align=center><b ><font size=4>Sunday</font></b></td>";
        w+="<td width=12% align=center><b ><font size=4>Monday</font></b></td>";
        w+="<td width=12% align=center><b ><font size=4>Tuesday</font></b></td>";
        w+="<td width=12% align=center><b ><font size=4>Wednesda y</font></b></td>";
        w+="<td width=13% align=center><b ><font size=4>Thursday </font></b></td>";
        w+="<td width=13% align=center><b ><font size=4>Friday</font></b></td>";
        w+="<td width=13% align=center><b ><font size=4>Saturday </font></b></td>";
        w+="</tr>";
        w+="</table>";
        document.write( w);
        }
        else

        if(f1.D1.value= =2)
        {
        var w="<table border=1 width=100%>";
        w+="<tr>";
        w+="<td width=12% align=center><b ><font size=4>Sunday</font></b></td>";
        w+="<td width=12% align=center><b ><font size=4>Monday</font></b></td>";
        w+="<td width=12% align=center><b ><font size=4>Tuesday</font></b></td>";
        w+="<td width=12% align=center><b ><font size=4>Wednesda y</font></b></td>";
        w+="<td width=13% align=center><b ><font size=4>Thursday </font></b></td>";
        w+="<td width=13% align=center><b ><font size=4>Friday</font></b></td>";
        w+="<td width=13% align=center><b ><font size=4>Saturday </font></b></td>";
        w+="</tr>";


        w+="</table>";

        document.write( w);
        }

        else
        if(f1.D1.value= =3)
        {
        var w="<table border=1 width=100%>";
        w+="<tr>";
        w+="<td width=12% align=center><b ><font size=4>Sunday</font></b></td>";
        w+="<td width=12% align=center><b ><font size=4>Monday</font></b></td>";
        w+="<td width=12% align=center><b ><font size=4>Tuesday</font></b></td>";
        w+="<td width=12% align=center><b ><font size=4>Wednesda y</font></b></td>";
        w+="<td width=13% align=center><b ><font size=4>Thursday </font></b></td>";
        w+="<td width=13% align=center><b ><font size=4>Friday</font></b></td>";
        w+="<td width=13% align=center><b ><font size=4>Saturday </font></b></td>";
        w+="</tr>";


        w+="</table>";

        document.write( w);

        }

        else
        if(f1.D1.value= =4)
        {
        var w="<table border=1 width=100%>";
        w+="<tr>";
        w+="<td width=12% align=center><b ><font size=4>Sunday</font></b></td>";
        w+="<td width=12% align=center><b ><font size=4>Monday</font></b></td>";
        w+="<td width=12% align=center><b ><font size=4>Tuesday</font></b></td>";
        w+="<td width=12% align=center><b ><font size=4>Wednesda y</font></b></td>";
        w+="<td width=13% align=center><b ><font size=4>Thursday </font></b></td>";
        w+="<td width=13% align=center><b ><font size=4>Friday</font></b></td>";
        w+="<td width=13% align=center><b ><font size=4>Saturday </font></b></td>";
        w+="</tr>";


        w+="</table>";

        document.write( w);
        }

        else
        if(f1.D1.value= =5)
        {
        var w="<table border=1 width=100%>";
        w+="<tr>";
        w+="<td width=12% align=center><b ><font size=4>Sunday</font></b></td>";
        w+="<td width=12% align=center><b ><font size=4>Monday</font></b></td>";
        w+="<td width=12% align=center><b ><font size=4>Tuesday</font></b></td>";
        w+="<td width=12% align=center><b ><font size=4>Wednesda y</font></b></td>";
        w+="<td width=13% align=center><b ><font size=4>Thursday </font></b></td>";
        w+="<td width=13% align=center><b ><font size=4>Friday</font></b></td>";
        w+="<td width=13% align=center><b ><font size=4>Saturday </font></b></td>";
        w+="</tr>";


        w+="</table>";

        document.write( w);
        }


        else
        if(f1.D1.value= =6)
        {
        var w="<table border=1 width=100%>";
        w+="<tr>";
        w+="<td width=12% align=center><b ><font size=4>Sunday</font></b></td>";
        w+="<td width=12% align=center><b ><font size=4>Monday</font></b></td>";
        w+="<td width=12% align=center><b ><font size=4>Tuesday</font></b></td>";
        w+="<td width=12% align=center><b ><font size=4>Wednesda y</font></b></td>";
        w+="<td width=13% align=center><b ><font size=4>Thursday </font></b></td>";
        w+="<td width=13% align=center><b ><font size=4>Friday</font></b></td>";
        w+="<td width=13% align=center><b ><font size=4>Saturday </font></b></td>";
        w+="</tr>";


        w+="</table>";

        document.write( w);
        }



        }

        </script>





        </head>


        <body onload=abc()>

        </body>

        </html>
        [/HTML]



        could u plz point out my mistakes and if possible give me the correct code...
        Last edited by r035198x; Mar 19 '07, 09:38 AM. Reason: added code tags

        Comment

        • acoder
          Recognized Expert MVP
          • Nov 2006
          • 16032

          #5
          Post your code please. What error are you getting?

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            Threads merged.

            Comment

            • star111792
              New Member
              • Jan 2007
              • 26

              #7
              Originally posted by acoder
              Threads merged.

              threads merged???? sorry unable to understand !!
              how this problem can be solved?

              Comment

              • acoder
                Recognized Expert MVP
                • Nov 2006
                • 16032

                #8
                Originally posted by star111792
                threads merged???? sorry unable to understand !!
                how this problem can be solved?
                Sorry about that. You double-posted on the same topic, so I merged the threads together.

                As for your problem, in your code, you have closed the form tag before writing the select dropdown. Why are you calling abc() every time you click on the go button? That will create duplicate forms.

                Comment

                • star111792
                  New Member
                  • Jan 2007
                  • 26

                  #9
                  i called abc() function repeatedly bcoz i want that the calender of the user's selected month should be displayed UNDER this drop-down list. and if user wants to make any selection from this list again,he/she does not have to press BACK button to go to this drop-down list.
                  even if i don't call the abc function repeatedly and close the form tag after writing the drop-down list, i m still getting the same error of "object required" as i click the OK button.

                  Comment

                  • acoder
                    Recognized Expert MVP
                    • Nov 2006
                    • 16032

                    #10
                    Instead of f1.d1, try:
                    Code:
                    document.f1.d1

                    Comment

                    Working...