VB script: newbee error: erorr with msgbox and forms
Hello everyone. I am a brand new, learner on VBscript, and I think I have an easy question. I need the following code to pop the first name, last name in the box below where the user will enter their information, but it does not pop up. I also want the telephone number seperated by ( ) around the area code, and a dash in between the number and exchange. Any help is greatly appreciated!
<HTML>
<BODY>
<FORM ACTION="msgbox" METHOD="POST">
Your Name: <INPUT TYPE="Text" NAME="name"><BR>
Your telephone: <INPUT TYPE="Text" NAME="email"><BR>
<BR>
Your results:<BR>
<TEXTAREA NAME="comment" COLS="20" ROWS="5" WRAP="VIRTUAL"></TEXTAREA><BR>
<INPUT TYPE="Submit" VALUE="Submit">
</FORM>
</BODY>
</HTML>
# 1 Re: VB script: newbee error: erorr with msgbox and forms
Hello & welcome! :wave:
You're going about it completely wrong, I'm afraid.
You can not use <FORM ACTION="msgbox" METHOD="POST"> in the manor you want to. The Action attribute in the form tag will either send the info from the form to a database, email, or even an asp page - definitely not to a msgbox. What you need to look into is the Document.value and Document.Writln statements to obtain info and write the info to the page. So look into the Document object of VBScript.
# 2 Re: VB script: newbee error: erorr with msgbox and forms
Is this what you are trying to accomplish?
<html>
<body>
<form name="frmlogin">
Name: <input type="text" name="name">
Telephone: <input type="text" name="telephone">
</form>
<script language="JavaScript">
retname = prompt("What is your name?", "");
retphone = prompt("What is your phone number?", "");
frmlogin.name.value = retname;
frmlogin.phone.value = retphone;
</script>
</body>
</html>
# 3 Re: VB script: newbee error: erorr with msgbox and forms
@Mssimofinance: Is this what you need
<HTML>
<HEAD>
<TITLE>VBSCript Example</TITLE>
<SCRIPT LANGUAGE="VBScript">
<!--
Sub Submit_OnClick
Dim TheForm
Set TheForm = Document.ValidForm
MsgBox("User Name = " & TheForm.uname.Value)
MsgBox("Telephone = = " & TheForm.utel.Value)
End Sub
-->
</SCRIPT>
</HEAD>
<BODY>
<FORM NAME="ValidForm">
Your Name: <INPUT TYPE="Text" NAME="uname"><BR>
Your telephone: <INPUT TYPE="Text" NAME="utel"><BR>
<BR>
<INPUT NAME="Submit" TYPE="BUTTON" VALUE="Submit">
</FORM>
</BODY>
</HTML>
@Paul: I think the OP needs it in VBScript, not JS :wave: