Results 1 to 5 of 5

Thread: HTML Form

  1. #1
    johnmergene is offline Member
    Join Date
    Jan 2011
    Location
    Baguio City, Philippines
    Posts
    21
    Rep Power
    0

    Post HTML Form

    I think it is not in a proper place. Can you help me how to submit form and store the values in a .csv file and post it in another html.

    Here is my code...
    <html>
    <head>
    <title>myForm</title>
    <script language="JavaScript">

    function WriteToFile(sText) {
    first=document.myform.GivenName.value;
    initial=document.myform.MiddleInitial.value;
    last=document.myform.Surname.value;
    f = document.getElementById("Course");
    course = f.options[f.selectedIndex].text;
    g = document.getElementById("year");
    year = g.options[g.selectedIndex].text;
    txtArea=document.myform.comments.value;
    for (var i=0; i < document.myform.gender.length; i++){
    if (document.myform.gender[i].checked){
    var rad_val = document.myform.gender[i].value;
    }
    }

    var fso = new ActiveXObject("Scripting.FileSystemObject");
    var d = fso.OpenTextFile("d:\\guest.csv", 8, true, 0);
    d.Write(first+",");
    d.Write(initial+",");
    d.Write(last+",");
    d.Write(rad_val+",");
    d.Write(course+",");
    d.Write(year+",");
    d.Write("COMMENTS:"+",");
    d.WriteLine(txtArea);
    }
    </script>
    </head>
    <body bgcolor="#000000" text="#FFFFFF">
    <form name="myform" onSubmit="WriteToFile(this)">
    Given Name:<input type ="text"name ="GivenName"value=""/><br>
    Middle Initial:<input type ="text"name ="MiddleInitial"value=""/><br>
    Surname:<input type ="text"name ="Surname"value=""/><br>
    Gender:<br>
    <input type="radio" name="gender"value = "male">Male
    <input type="radio" name="gender"value = "female" >Female


    <P>Course: <SELECT id="Course" SIZE="1">
    <OPTION value="1" selected="selected">-
    <OPTION value="2">Bachelor of Science in Information Technology (B.S.I.T)
    <OPTION value="3">Bachelor of Science in Computer Sciences (B.S.C.S)
    <OPTION value="4">Bachelor of Science in Information Management (B.S.I.M)
    <OPTION value="5">Bachelor of Scinece in Nursing(B.S.N)
    <OPTION value="6">Bachelor of Scinece in Elecetrical Engineering(B.S.E.C.E)

    </SELECT>
    <P>YEAR: <SELECT id="year" SIZE="1">
    <OPTION value="1" selected="selected">-
    <OPTION value="2">1
    <OPTION value="3">2
    <OPTION value="4">3
    <OPTION value="5">4
    <OPTION value="6">5

    </SELECT>
    <br>Comments:<br>
    <textarea name="comments" rows="10" cols="120" value=""></textarea>
    <br>
    <br>
    <input type="submit" value="submit" />

    <input type="reset" value="clear" onClick="clear()" />
    </form>
    </body>
    </html>

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Yours is a JavaScript question, not a Java question, and it should be asked in a JavaScript forum. Google can help you find one of these.

  3. #3
    johnmergene is offline Member
    Join Date
    Jan 2011
    Location
    Baguio City, Philippines
    Posts
    21
    Rep Power
    0

    Default

    thanks but. i cant find it.. hmm... thanks anyway

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by johnmergene View Post
    thanks but. i cant find it.. hmm... thanks anyway
    Google is down in your part of the world? That's a shame. When I did a Google search on JavaScript forum, I got tons of decent hits.

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

Similar Threads

  1. unknown html:form tag error.Pls help
    By yss1287b in forum New To Java
    Replies: 0
    Last Post: 12-14-2010, 11:31 PM
  2. Html form
    By redforce.bala in forum Advanced Java
    Replies: 1
    Last Post: 10-04-2010, 03:07 PM
  3. Replies: 10
    Last Post: 08-12-2009, 05:02 PM
  4. Two Form Applet in html
    By barusk in forum Java Applets
    Replies: 0
    Last Post: 03-16-2009, 06:36 PM
  5. HTML Form
    By Java Tip in forum SWT Tips
    Replies: 0
    Last Post: 07-11-2008, 05:37 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •