Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 984
  • Last Modified:

pass vbscript variable to html textbox

I have vbscript in an html page that is generating a value for a variable.  I have a standard textbox on the same html page that I would like to make the value = to the variable.  How do I go about this?
0
dale4brumbaugh
Asked:
dale4brumbaugh
  • 6
  • 6
  • 4
1 Solution
 
thenoneCommented:
I would use cookies or sessions for this.
0
 
gjutrasCommented:
make sure the textbox has an id= in the html tag.

then the code is
document.form(0).textboxid.value = variable

assuming there's only one form on the page.
0
 
gjutrasCommented:
Also make the name= the same as the id=
so
<input type="text" name="MyTextBox" id="MyTextBox" >
would use
document.form(0).MyTextBox.value = myvariable
to set the contents of the textbox to what myvariable contains.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
dale4brumbaughAuthor Commented:
When using the last 2 methods, I get an "Object doesn't support this property or method" error.  I have the id set on the textbox and added the suggestion to the vbscript language.  Any suggestions?
0
 
thenoneCommented:
post the code.
0
 
dale4brumbaughAuthor Commented:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
</head>
<body>
<script language="vbscript">
dim name
name = int((datediff("s","12/31/2004",date) + timer)*1000)
document.test.T1.value=name
</script>
<form method="POST" action="--WEBBOT-SELF--" name="test">
      <!--webbot bot="SaveResults" U-File="_private/form_results.csv" S-Format="TEXT/CSV" S-Label-Fields="TRUE" -->
      <p><input type="text" name="T1" id=T1 size="20"></p>
      <p>&nbsp;</p>
      <p><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
</form>
</body>
</html>
0
 
thenoneCommented:
="--WEBBOT-SELF ? get rid of this. get rid of action="--webbot-self
0
 
dale4brumbaughAuthor Commented:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
</head>
<body>
<script language="vbscript">
dim name
name = int((datediff("s","12/31/2004",date) + timer)*1000)
document.test.T1.value=name
</script>
<form method="POST" name="test">
      <p><input type="text" name="T1" id=T1 size="20"></p>
      <p>&nbsp;</p>
      <p><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
</form>
</body>
</html>

I still get the same error.
0
 
thenoneCommented:
ok I put the code into a web page and I recieved no error. What exactly are you trying to do and I will re-write it.
0
 
dale4brumbaughAuthor Commented:
Ok, in a web page I don't get an error either (was getting error in Frontpage using preview).  In your test, does anything appear in the textbox as a value?  What I am trying to do is to have a very simple method of generating a unique (I know in theory my formula isn't unique but it will do what I need) and then posting it to the textbox for user reference.
0
 
thenoneCommented:
ok forget about frontpage ill hand code it. What value do you posted how do you want it posted and what does the user enter in if any. Also does the page retain the value if the user returns to the site.
0
 
dale4brumbaughAuthor Commented:
For what I need I simply need a textbox in a form to get the value from the following vbscript:
<script language="vbscript">
dim name
name = int((datediff("s","12/31/2004",date) + timer)*1000)
</script>

The value does not need to be retained. The user will not enter anything for the purpose of this example.
0
 
thenoneCommented:
So another words the value will be placed into the text box?
0
 
dale4brumbaughAuthor Commented:
yes
0
 
gjutrasCommented:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
<script language="vbscript">
sub LoadDate
dim mydate
mydate = int((datediff("s","12/31/2004",date) + timer)*1000)
document.testform.T1.value=mydate
end sub
</script>
</head>
<body onLoad="LoadDate">
<form method="POST" name="testform">
      <p><input type="text" name="T1" id=T1 size="20"></p>
      <p>&nbsp;</p>
      <p><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
</form>
</body>
</html>
0
 
gjutrasCommented:
I wouldn't use the name or id name as its a keyword and could cause a conflict.  I changed test and name to different names and put the call in a function and put the call in the body 's onLoad event.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 6
  • 6
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now