Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Easy Web Question

Status
Not open for further replies.

jasonp45

Programmer
Aug 23, 2001
212
0
0
US
I have a textbox form on a page

<input type=&quot;TEXT&quot; name=&quot;Subject&quot; size=&quot;50&quot;> <br>

and I want to set it equal to some text when a button is pressed

<INPUT id=&quot;cmd2&quot; type=submit value=&quot;Display Data Structure&quot; name=&quot;DDS&quot; LANGUAGE=vbscript>

<Script Language=VBScript>
Sub cmd2_OnClick()
[Set TextBox &quot;Subject&quot; = [SomeText]] ?????
End Sub
</Script>

How do I do this?

Then, when I want to capture that text with an ASP page, what is syntax to refer to the textbox form? Something like sText = Request.Form(&quot;Subject&quot;)?
 
<Script Language=VBScript>
Sub cmd2_OnClick()
document.[formname].Subject.value = [SomeText]
End Sub
</Script>

That should do it.

Mike
 
Thanks MNClimber - that worked. Now how do I get my ASP page to capture the value of the textbox?

I have an ASP page with the following code:

<Script Language=VBScript>
Dim sFileName
Dim sTextToWrite
Dim oFile
Dim oFSO
sFileName = &quot;C:\ASPTest.txt&quot;
sTextToWrite = Request.Form(&quot;document.ReturnStructure.Subject.value&quot;)
Set oFSO = CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set oFile = oFSO.CreateTextFile(sFileName, True)
oFile.Close
Set oFile = Nothing
Set oFile = oFSO.OpenTextFile(sFileName, 2, True)
oFile.Write sTextToWrite
oFile.Close
Set oFile = Nothing
Set oFSO = Nothing
</Script>

It works (creates a textfile with some text in it) if I set sTextToWrite equal to some actual text, but [Request.Form(&quot;document.ReturnStructure.Subject.value&quot;)] causes an error, as does [Request.Form(&quot;Subject&quot;)].

I'm sure it's a simple syntax thing.
 
Is your form set to use &quot;method=post&quot; or &quot;method=get&quot;

If it's the &quot;get&quot; one then you would need:
Request.QueryString(&quot;Subject&quot;)

Mike
 
I should probably add...I believe that the get method is default, and that is where the data sent is visible in the address bar of the browser.

Post method is not sent using the address bar and that is where you use Request.Form(&quot;VarName&quot;).

You can also use Request(&quot;VarName&quot;) and it will work either way, but I have read about a performance hit doing that...I am not sure of how much of one.

HTH

Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top