dcsimg
Results 1 to 3 of 3
  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2018
    Posts
    2

    Unhappy Html form to excel sheet using java script?

    Morning All,
    I am new to the site so forgive me if this is in wrong section or if the message is lengthy.
    What i am trying to do is create a single web page that has text fields and radio buttons to allow a user to input data using a touch screen prior to hitting a submit button and for that data to be sent to a single excel file.

    Now i have found the following code and it works as it is but unsure on how to get radio buttons to work?


    Code:
    Code:
    <!DOCTYPE html>
    <html>
    <head>
    <script language="vbscript" type="text/vbscript">
    Sub Sample()
    Dim iRow
    Set objExcel = CreateObject("Excel.Application")
    Set objWorkbook = objExcel.Workbooks.Open("home/Book1.xlsx
    'Document.GetElementsByName("fname")(0).Value="C#"
    'Document.GetElementsByName("lname")(0).Value="Corner"
    'Document.GetElementsByName("Add1")(0).Value="Tamilnadu"
    'Document.GetElementsByName("Add2")(0).Value="Coimbatore"
    objExcel.Application.Visible = True
    objWorkbook.Windows(1).Visible = True
    set XlSheet =objWorkbook.Sheets(1)
    XlSheet.Activate
    iRow = 1
    With objExcel
    Do While .Cells(iRow, 1).value <> ""
    .Cells(iRow, 1).activate
    iRow = iRow + 1
    Loop
    .Cells(iRow, 1).value=Document.GetElementsByName("fname")(0).Value
    .Cells(iRow, 2).value=Document.GetElementsByName("lname")(0).Value
    .Cells(iRow, 3).value=Document.GetElementsByName("Add1")(0).Value
    .Cells(iRow, 4).value=Document.GetElementsByName("Add2")(0).Value
    MsgBox "Data Added Sucessfully",vbinformation
    Document.GetElementsByName("fname")(0).Value=""
    Document.GetElementsByName("lname")(0).Value=""
    Document.GetElementsByName("Add1")(0).Value=""
    Document.GetElementsByName("Add2")(0).Value=""
    End With
    objWorkbook.save
    objWorkbook.close
    Set objWorkbook = Nothing
    Set objExcel = Nothing
    End Sub
    </script>
    
    <body>
    <form>
    <fieldset>
    
    <center>
    
    First name:<br> 
    <input type="text" name="fname" Value=""><br>
    Last name:<br>
    <input type="text" name="lname" Value=""><br>
    Address1:<br>
    <input type="text" name="Add1" Value=""><br>
    Address2 :<br>
    <input type="text" name="Add2" Value=""><br>
    <br>
    <input type="button" onclick="Sample()" value="Submit" /><br>
    </center>
    </fieldset>
    </form>
    </body>
    </html>
    Also i am not too sure what the values are for at the ends of the following line of coding?
    Code:
    'Document.GetElementsByName("fname")(0).Value="C#"
    'Document.GetElementsByName("lname")(0).Value="Corner"
    'Document.GetElementsByName("Add1")(0).Value="Tamilnadu"
    'Document.GetElementsByName("Add2")(0).Value="Coimbatore"
    Hope there is someone on this forum who is able to help at all.


    Kind Regards
    P
    Last edited by si_the_geek; Jun 27th, 2018 at 07:59 AM. Reason: changed Quote tags to Code tags

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    39,938

    Re: Html form to excel sheet using java script?

    Welcome to VBForums

    Thread moved from the 'VB.Net' forum to the 'VBScript' forum (you've mentioned Javascript in the thread title, but it is VBScript you are using)

  3. #3

    Thread Starter
    New Member
    Join Date
    Jun 2018
    Posts
    2

    Re: Html form to excel sheet using java script?

    Thanks Si,
    I wasn't too sure myself as just looking on line at really old posts etc, some places say it cant be done but that coding actually works but i need my form to be more detailed than just four fields and to have radio buttons and check boxes as well for the end user.

    Regards
    P

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width