HTML input to variable and pass to vbscript, Inout form to gather user input and pass input as variable to vbscript |
HTML input to variable and pass to vbscript, Inout form to gather user input and pass input as variable to vbscript |
EDL |
Mar 3 2015, 10:48 AM
Post
#1
|
Group: Members Posts: 3 Joined: 3-March 15 Member No.: 22,306 |
Hello,
Very much a newbie and need some help. I want to take a very basic, very simple HTML form that asks a user for three pieces of information. The information needs to go into a variable that an embedded VBScript can use to send an email via SMTP relay. I can do it all in straight VBScript with input boxes, but an HTMl form allows it to be prettier. I need this form to work because it is needed on systems for users who do not have email access or Outlook (RDP sessions to a TS for very limited purposes). I have this, and it will send the email, but none of the input is included in the email. Not sure how to capture the user input as variables so the VBScript code will add to email text body: <HTML> <HEAD> <TITLE>Form</TITLE> <script language="VBScript"> sub runsend Set emailObj = CreateObject("CDO.Message") emailObj.From = "from@some.com" emailObj.To = "recipient@some.com" emailObj.Subject = "Made up subject" emailObj.TextBody = "User: " & name & vbCrLf & vbCrLf + "Work Area: " & WorkArea & vbCrLf & vbCrLf + "Issue: " & Issue Set emailConfig = emailObj.Configuration emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "my smtp server" emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 emailConfig.Fields.Update emailObj.Send End sub </SCRIPT> </head> <BODY> <FORM NAME="Form"> Name:<br> <input type="text" name="name"> <br> Work Area:<br> <input type="text" name="WorkArea"> <br> Issue:<br> <input type="text" name="Issue"> <br><BR> <BUTTON onclick="runsend">Submit</button> </BODY> </HTML> This post has been edited by EDL: Mar 3 2015, 10:50 AM |
CharlesEF |
Mar 3 2015, 12:31 PM
Post
#2
|
Programming Fanatic Group: Members Posts: 1,981 Joined: 27-April 13 From: Edinburg, Texas Member No.: 19,088 |
First, I do not recommend using Javascript because users can turn it off. Second, if you use vbScript then you are limited to using IE only. No other browser supports it.
Your 3 fields are HTML elements not variables. You need to assign them an 'id' and use the command document.getElementById('name').value for each (change the id for each). |
EDL |
Mar 3 2015, 04:39 PM
Post
#3
|
Group: Members Posts: 3 Joined: 3-March 15 Member No.: 22,306 |
First, I do not recommend using Javascript because users can turn it off. Second, if you use vbScript then you are limited to using IE only. No other browser supports it. Your 3 fields are HTML elements not variables. You need to assign them an 'id' and use the command document.getElementById('name').value for each (change the id for each). Users are very restricted on this system (they can't even right-click). IE is the only browser on the system. So do I need to assign a variable value in the vbscript portion with document.getElementById("name").value and then call that variable in emailObj.Textbody? Something like: sub runsend un=document.getElementById("username").value with "username" being id of the element Then, in the email sending portion of the vbscript place the "un" variable in the textbody to show that input? |
EDL |
Mar 3 2015, 09:39 PM
Post
#4
|
Group: Members Posts: 3 Joined: 3-March 15 Member No.: 22,306 |
First, I do not recommend using Javascript because users can turn it off. Second, if you use vbScript then you are limited to using IE only. No other browser supports it. Your 3 fields are HTML elements not variables. You need to assign them an 'id' and use the command document.getElementById('name').value for each (change the id for each). Users are very restricted on this system (they can't even right-click). IE is the only browser on the system. So do I need to assign a variable value in the vbscript portion with document.getElementById("name").value and then call that variable in emailObj.Textbody? Something like: sub runsend un=document.getElementById("username").value with "username" being id of the element Then, in the email sending portion of the vbscript place the "un" variable in the textbody to show that input? AH! I figured it out. I needed to declare the variables above the sub runsend. All working now, thank you! |
Lo-Fi Version | Time is now: 29th March 2024 - 04:27 AM |