Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


passing variables

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,51913
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> passing variables
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 passing variables - 9/17/2007 12:37:21 PM   
  Tin

 

Posts: 15
Score: 0
Joined: 8/30/2007
Status: offline
Hi all
I have made it this far.
the following code doesn't work, but is there to help you understand what I am trying to do.
well the code does work if I put the document.write in the sub instead of the table.

What I would like to do is have the variable "ts" displayed in the table cell.
but I am parsing this, so I will want different pieces of the string in different cells.
I think it doesn't work because I am trying to use the variable outside the sub, but I thought the "public sub viewdata()" would solve that but it didn't.

I really don't want to put the entire script in each table cell which is the only way i can get it to work.

can someone help me here pls, keeping as much of my coding as possible so I can understand without getting totally lost.
thanks,
Tin


<SCRIPT LANGUAGE="VBScript">
Public Sub viewdata()
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("C:/Documents and Settings/test.txt", ForReading)
Dim tl
tl = objTextFile.Readall
Dim ts
ts =split(tl, ",")

End Sub
</script>
<table width="100%" border="3" cellspacing="0" cellpadding="0">
<tr>
   <td width="20%">month</td>
   <td width="20%">amount</td>
   <td>&nbsp;</td>
   <td width="20%">comments</td>
   <td width="20%">&nbsp;</td>
</tr>
<tr>
   <td><script type="text/vbscript">
document.write ts(0)
</script></td>
    <td></td>
   <td></td>
   <td>&nbsp;</td>
   <td>&nbsp;</td>
</tr>
</table>
 
 
Post #: 1
 
 RE: passing variables - 9/17/2007 3:59:17 PM   
  sheepz


Posts: 247
Score: 2
Joined: 3/17/2006
From: Riverside the 909s
Status: offline
i'm not too familiar with Public Sub and it's behavior.  could you use a function?  something like this:

<SCRIPT LANGUAGE="VBScript">
Function viewdata()
Dim ts, tl
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("C:/Documents and Settings/test.txt", ForReading)
tl = objTextFile.Readall
ts =split(tl, ",")
viewdata = ts(0)  '<--- Assign return value
End Function
</script>
<table width="100%" border="3" cellspacing="0" cellpadding="0">
<tr>
  <td width="20%">month</td>
  <td width="20%">amount</td>
  <td>&nbsp;</td>
  <td width="20%">comments</td>
  <td width="20%">&nbsp;</td>
</tr>
<tr>
  <td><script type="text/vbscript">
      document.write viewdata()  '<--- Function return value
      </script></td>
  <td></td>
  <td></td>
  <td>&nbsp;</td>
  <td>&nbsp;</td>
</tr>
</table>


sounds like the Public Sub should work.  i mean it's Public so it sounds like it should be able to pass variables, but maybe we're not passing it correctly... maybe someone can let us know are we using the Public Sub correctly?  is it meant for a specific method/function?  when would we use a Public Sub?

(in reply to Tin)
 
 
Post #: 2
 
 RE: passing variables - 9/17/2007 7:29:22 PM   
  ginolard


Posts: 1082
Score: 21
Joined: 8/10/2005
Status: offline
Nah, Public and Private don't have any meaning in scripts like that.  They're only useful when creating Classes.

Using a function or a global variable (i.e putting the Dim TS statement outside of all Subs/Functions) are your best options.

_____________________________

Author of ManagePC - http://managepc.net
AD Query Template - http://www.visualbasicscript.com/m_40609/tm.htm
Consolidated Scripting Framework - http://www.visualbasicscript.com/m_59109/tm.htm

(in reply to sheepz)
 
 
Post #: 3
 
 RE: passing variables - 9/18/2007 3:47:44 AM   
  Tin

 

Posts: 15
Score: 0
Joined: 8/30/2007
Status: offline
thanks folks,
I will try putting the variables outside the sub

(in reply to ginolard)
 
 
Post #: 4
 
 RE: passing variables - 9/18/2007 1:21:25 PM   
  Tin

 

Posts: 15
Score: 0
Joined: 8/30/2007
Status: offline
ok,
I did get the function procedure working as well as putting variables outside the sub/function
I got it working in both instances.

I have been working on adding to the script  it all day with many successes but I am stuck
I am now reading the text file, and then finding a line in the file. The line of text has 4 words with a delimiter as ","
After finding this particular line, place each of the 4 words into 4 different cells within the table.
using sheepz example of re-writing the procedure to a function instead of sub, worked fine if I only wish to call the first word in the line of text
"viewdata = ts(0)" if there are 4 words in the line of text I wish to call into the tables 4 cells, how would I do this??

here is my latest attempt:

<SCRIPT LANGUAGE="VBScript">
ts = 0
Function viewdata(id, comment, month, cost)
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("C:/Documents and Settings/test.txt", ForReading)
Do
Dim tl
tl = objTextFile.ReadLine
Dim ts
ts =split(tl, ",")
cur_num = ts(0)
loop Until cur_num = "2"
ts(0) = viewdata(id)
ts(1) = viewdata(comment)
ts(2) = viewdata(month)
ts(1) = viewdata(cost)
End Function
objTextFile.Close
</script>
<table width="100%" border="3" cellspacing="0" cellpadding="0">
<tr>
   <td width="20%">Entry #</td>
   <td width="20%">month</td>
   <td width="20%">amount</td>
   <td width="20%">comments</td>
</tr>
<tr>
<td>&nbsp;<script type="text/vbscript">
document.write viewdata(id)
</script></td>
   <td><script type="text/vbscript">
document.write viewdata(comment)
</script></td>
   <td><script type="text/vbscript">
document.write viewdata(month)
</script></td>   
   <td><script type="text/vbscript">
document.write viewdata(cost)
</script></td>
</tr>
</table>

<input type="button" id="viewbutton" value="View" name="viewbutton" onClick="viewdata(id, comment, month, cost)">

(in reply to Tin)
 
 
Post #: 5
 
 RE: passing variables - 9/18/2007 5:08:49 PM   
  sheepz


Posts: 247
Score: 2
Joined: 3/17/2006
From: Riverside the 909s
Status: offline
do you look for a specific line in the text file? or is there only one line?  because you dont have a search method your just reading the line:

tl = objTextFile.ReadLine
Dim ts
ts =split(tl, ",")
cur_num = ts(0)


i dont know how the text file looks like so i commented out the text parts and manually inserted four words with "," as delimiter:
<SCRIPT LANGUAGE="VBScript">
Function viewdata()
Dim ts, tl
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Set objTextFile = objFSO.OpenTextFile("C:/Documents and Settings/test.txt", ForReading)
'tl = objTextFile.Readall
'ts =split(tl, ",")
ts = "pizza,soda,fries,sandwich"   '<---- Simulating text line
viewdata = ts   '<--- Assign return value to function before split
End Function
</script>
<table width="100%" border="3" cellspacing="0" cellpadding="0">
<tr>
  <td width="20%">month</td>
  <td width="20%">amount</td>
  <td>&nbsp;</td>
  <td width="20%">comments</td>
  <td width="20%">&nbsp;</td>
</tr>
<tr>
  <td><SCRIPT LANGUAGE="VBScript">
       arrParts = Split(viewdata(), ",")   '<--- Split Function value
       document.write arrParts(0)
      </script></td>
  <td><script type="text/vbscript">
     document.write arrParts(1)  '<--- Write split values
     </script></td>
  <td><script type="text/vbscript">
     document.write arrParts(2)  '<--- Write split values
     </script></td>
  <td><script type="text/vbscript">
     document.write arrParts(3)  '<--- Write split values
     </script></td>
</tr>
</table>


i'm not sure if this is the proper way, just something i use.   i'm positive you can do it with the dictionary object, im just not too sure how.  hopefully someone can give us an example... hope this helps

(in reply to Tin)
 
 
Post #: 6
 
 RE: passing variables - 9/19/2007 8:14:13 AM   
  Tin

 

Posts: 15
Score: 0
Joined: 8/30/2007
Status: offline
Thanks sheepz.
I didn't think of splitting the line of text outside the function.

There is going to be many lines in the text file. When I write them using some vbs, I number the lines. So I am getting the vbs to search through the lines until it finds an "ID" number entered by the user (user entry is currently hard coded at "2" ), using my do loop:
Do
Dim tl
tl = objTextFile.ReadLine
Dim ts
ts =split(tl, ",")
cur_num = ts(0)
loop Until cur_num = "2"  ' when reading each line of text, it will stop when it finds the number "2" in the first split of the text file (which is line 2 of course)

this works fine.
I understand what you did by splitting the text file outside the function, good idea.
BUT you will see I don't want the function to be called until the "submit" button
<input type="button" id="viewbutton" value="View" name="viewbutton" onClick="viewdata()">

Any ideas how I can get each of the 4 words on 1 line of text in the text file to appear seperately in each of the 4 table cells when I use the button to call the function?
thanks
Tin


(in reply to sheepz)
 
 
Post #: 7
 
 RE: passing variables - 9/19/2007 1:00:57 PM   
  sheepz


Posts: 247
Score: 2
Joined: 3/17/2006
From: Riverside the 909s
Status: offline
okie, i'm not good at hta's at all so here's what i use... it's NOT the correct way, hopefully someone could show us both how to do it properly, but here goes:

<SCRIPT LANGUAGE="VBScript">
Function viewdata()
Dim ts, tl
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Set objTextFile = objFSO.OpenTextFile("C:/Documents and Settings/test.txt", ForReading)
'tl = objTextFile.Readall
'ts =split(tl, ",")
ts = "pizza,soda,fries,sandwich"
viewdata = ts '<--- Assign return value to function before split
End Function
</script>
<table width="100%" border="3" cellspacing="0" cellpadding="0">
<tr>
  <td width="20%">month</td>
  <td width="20%">amount</td>
  <td>&nbsp;</td>
  <td width="20%">comments</td>
  <td width="20%">&nbsp;</td>
</tr>
<tr>
  <td><SCRIPT LANGUAGE="VBScript">
       Sub BtnStart   '<--- When user clicks Start, activate split
        arrParts = Split(viewdata(), ",")   '<--- Split Function value
        HTML = "<table width='100%' border='1'><tr>" & _    '<--- create variable with html table
               "<td width='20'>" & arrParts(0) & "</td>" & _      
               "<td width='20'>" & arrParts(1) & "</td>" & _
               "<td width='20'>" & arrParts(2) & "</td>" & _
               "<td width='20'>" & arrParts(3) & "</td>" & _
               "<td width='20'> Empty </td>"
        window.document.getElementById("dispstatus").innerHTML = HTML & "</table>"   '<--- tell it to append to the end of the html
       End Sub
      </script></td></tr>
<!-- Submit button --> 
<input type="button" value="Start" onClick="BtnStart">   '<--- Start button that calls Sub BtnStart
</table>
<span id="dispstatus"></span>  '<--- getElementById("dispstatus") needs this, not sure how it works
 
 
i'm very new to hta's not sure how all the commands work

(in reply to Tin)
 
 
Post #: 8
 
 RE: passing variables - 9/19/2007 2:50:01 PM   
  Tin

 

Posts: 15
Score: 0
Joined: 8/30/2007
Status: offline
Hi Sheepz
Thanks for your help, that post is quite beyond my abilities. Statements like: window.document.getElementById("dispstatus").innerHTML = HTML & "</table>"   

I have been working on it and I had an idea.
Somehow with the button I had to call a procedure that would fill the 4 cells in the table.
Would something like this work?

I will call a new function with my button:
<input type="button" id="viewbutton" value="View" name="viewbutton" onClick="filltable()">

in the head I have that function:
<script type="text/vbscript">
i = 0
Function filltable()
i = 1
filltable = i
document.write filltable 'this line for testing purposes
End Function
</script>

just after the open body tag I have:
<script type="text/vbscript">
filltable() = 0
</script>

I kept your idea of splitting the text string outside the viewdata function:
<script type="text/vbscript">
query_line = split(viewdata(), ",")
</script>

and then I wrote this into each table cell:
<td>&nbsp;<script type="text/vbscript">
If filltable() = 0 Then document.write ("na") ' I have tried = 1 <> 1 and ="" depending on the structure of the statement
  Else document.write query_line(0) 
</script></td>

I hope you can see the logic I am trying for but this doesn't seem to work.
It seems that my filltable() function is read by the page immediately.
I thought a function wasn't read until called upon.

any ideas on this type of logic?
Can this work?
Thanks,
Tin

entire current code is below:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<script type="text/vbscript">
Function filltable()
i = 1
filltable = i
document.write filltable
End Function
</script>
</head>
<body>
<script type="text/vbscript">
filltable() = 0
</script>
<p>&nbsp;</p>
<p>
<SCRIPT LANGUAGE="VBScript">
ts = 0
Function viewdata()
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("C:/Documents and Settings/test.txt", ForReading)
Do
Dim tl
tl = objTextFile.ReadLine
Dim ts
ts =split(tl, ",")
cur_num = ts(0)
loop Until cur_num = "2"
viewdata = tl

End Function
objTextFile.Close
</script>

<script type="text/vbscript">
query_line = split(viewdata(), ",")
</script>

</p>
<table width="100%" border="3" cellspacing="0" cellpadding="0">
<tr>
   <td width="20%">Entry #</td>
   <td width="20%">month</td>
   <td width="20%">amount</td>
   <td width="20%">comments</td>
</tr>
<tr>
<td>&nbsp;<script type="text/vbscript">
If filltable() = 0 Then document.write ("na")
Else document.write query_line(0)

</script></td>
   <td><script type="text/vbscript">
If filltable() = 0 Then document.write ("na")
Else document.write query_line(2)
</script></td>

   <td><script type="text/vbscript">
If filltable() = 0 Then document.write ("na")
Else document.write query_line(3)
</script></td>   
   <td><script type="text/vbscript">
  If filltable() = 0 Then document.write ("na")
  Else document.write query_line(1)
</script></td>
</tr>
</table>

view which record<input name="rec_num" id="rec_num" maxlength="10">
<input type="button" id="viewbutton" value="View" name="viewbutton" onClick="filltable()">

</body>
</html>

(in reply to sheepz)
 
 
Post #: 9
 
 RE: passing variables - 9/20/2007 11:55:17 AM   
  Tin

 

Posts: 15
Score: 0
Joined: 8/30/2007
Status: offline
Ok,
I got it.
I have had to use the object method which I prefer not to, but it works.
If anyone can offer me a way to load the cells with the data without using the object method i would REALLY appreciate it.

now I do have one problem:
I need an input for the user to select which line of text they wish to be displayed in the table. Right now I have hard coded it to a value of 2
well it's easier to explain in the code:

<head>
<title>Untitled Document</title>
<script type="text/vbscript">
Sub ctc_onclick
Document.output_line.lineid.Caption = query_line(0)
Document.output_line.month.Caption = query_line(2)
Document.output_line.amount.Caption = query_line(3)
Document.output_line.comments.Caption = query_line(1)
End Sub

Function viewdata()
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("C:/Documents and Settings/test.txt", ForReading)
Do
Dim tl
tl = objTextFile.ReadLine
Dim ts
ts =split(tl, ",")
cur_num = ts(0) 'reads first string in  line of the text
loop Until cur_num = 2 'I would like the 2 to be the users input from the input box down below rec_num value but I am having a hard time accomplishing this

viewdata = tl
objTextFile.Close
End Function
</script>
</head>
<body>

<script type="text/vbscript">
query_line = split(viewdata(), ",")
</script>
<form name="output_line">
<table width="100%" border="3" cellspacing="0" cellpadding="0">
<tr>
   <td width="20%">Entry #</td>
   <td width="20%">month</td>
   <td width="20%">amount</td>
   <td width="20%">comments</td>
</tr>
<tr>
<td>&nbsp;<OBJECT ID="lineid" WIDTH=100 HEIGHT=24
 CLASSID="CLSID:978C9E23-D4B0-11CE-BF2D-00AA003F40D0">
    <PARAM NAME="ForeColor" VALUE="0">
    <PARAM NAME="BackColor" VALUE="16777215">
    <PARAM NAME="Caption" VALUE="">
    <PARAM NAME="Size" VALUE="1582;635">
    <PARAM NAME="SpecialEffect" VALUE="2">
    <PARAM NAME="FontHeight" VALUE="200">
    <PARAM NAME="FontCharSet" VALUE="0">
    <PARAM NAME="FontPitchAndFamily" VALUE="2">
    <PARAM NAME="ParagraphAlign" VALUE="2">
    <PARAM NAME="FontWeight" VALUE="0">
</OBJECT></td>
   <td><OBJECT ID="month" WIDTH=100 HEIGHT=24
 CLASSID="CLSID:978C9E23-D4B0-11CE-BF2D-00AA003F40D0">
    <PARAM NAME="ForeColor" VALUE="0">
    <PARAM NAME="BackColor" VALUE="16777215">
    <PARAM NAME="Caption" VALUE="">
    <PARAM NAME="Size" VALUE="1582;635">
    <PARAM NAME="SpecialEffect" VALUE="2">
    <PARAM NAME="FontHeight" VALUE="200">
    <PARAM NAME="FontCharSet" VALUE="0">
    <PARAM NAME="FontPitchAndFamily" VALUE="2">
    <PARAM NAME="ParagraphAlign" VALUE="2">
    <PARAM NAME="FontWeight" VALUE="0">
</OBJECT></td>

   <td><OBJECT ID="amount" WIDTH=100 HEIGHT=24
 CLASSID="CLSID:978C9E23-D4B0-11CE-BF2D-00AA003F40D0">
    <PARAM NAME="ForeColor" VALUE="0">
    <PARAM NAME="BackColor" VALUE="16777215">
    <PARAM NAME="Caption" VALUE="">
    <PARAM NAME="Size" VALUE="1582;635">
    <PARAM NAME="SpecialEffect" VALUE="2">
    <PARAM NAME="FontHeight" VALUE="200">
    <PARAM NAME="FontCharSet" VALUE="0">
    <PARAM NAME="FontPitchAndFamily" VALUE="2">
    <PARAM NAME="ParagraphAlign" VALUE="2">
    <PARAM NAME="FontWeight" VALUE="0">
</OBJECT></td>   
   <td><OBJECT ID="comments" WIDTH=100 HEIGHT=24
 CLASSID="CLSID:978C9E23-D4B0-11CE-BF2D-00AA003F40D0">
    <PARAM NAME="ForeColor" VALUE="0">
    <PARAM NAME="BackColor" VALUE="16777215">
    <PARAM NAME="Caption" VALUE="">
    <PARAM NAME="Size" VALUE="1582;635">
    <PARAM NAME="SpecialEffect" VALUE="2">
    <PARAM NAME="FontHeight" VALUE="200">
    <PARAM NAME="FontCharSet" VALUE="0">
    <PARAM NAME="FontPitchAndFamily" VALUE="2">
    <PARAM NAME="ParagraphAlign" VALUE="2">
    <PARAM NAME="FontWeight" VALUE="0">
</OBJECT></td>
</tr>
</table>

view which record<input type="text" name="rec_num" id="rec_num" maxlength="10">
<input type="button" id="viewbutton" value="view" name="ctc" >
</form>

Thanks sheepz for helping me on this and thanks to anyone who offers their input

Tin

(in reply to Tin)
 
 
Post #: 10
 
 RE: passing variables - 9/20/2007 3:39:31 PM   
  sheepz


Posts: 247
Score: 2
Joined: 3/17/2006
From: Riverside the 909s
Status: offline
sorry been really busy at work... theres a way to use the Dictionary Object to display results when user hits the submit button i'm just not sure how... it just occurred to me but is this an .HTML file with vbscript embedded or is this an .HTA?  because the syntax will be different... my examples are in HTA, let me know if your using .HTML file... here is a sample of grabbing user input, a string and a number:

<html>
<head>
<title>Grab user input</title>
<script language="vbscript">
Sub strOutput
Text = window.document.getElementById("strText").value  'Grab text field value
MsgBox Text
End Sub
Sub numOutput
Num = cint(window.document.getElementById("iNum").value)  'Grab number field value
MsgBox Num
End Sub
</script>
<table>
<tr><td>
     Sample String input <input type="text" id="strText" size="15"></td>  <!-- text field -->
   <td>
     <input type="button" value="Display Text" onClick="strOutput"></td>
</tr>
<tr><td>
     Sample Number input <input type="text" id="iNum" size="15"></td>    <!-- number field --> 
   <td>
     <input type="button" value="Display Number" onClick="numOutput"></td>
</tr>
</table>
</html>

< Message edited by sheepz -- 9/21/2007 12:01:51 PM >

(in reply to Tin)
 
 
Post #: 11
 
 RE: passing variables - 9/21/2007 2:43:22 PM   
  Tin

 

Posts: 15
Score: 0
Joined: 8/30/2007
Status: offline
Hi sheepz
It's an html file, to answer your question.
Would you mind showing me your example in .html
I would like to see what it looks like since I am not very familiar with .hta's

I also would like to thank you for all your help.
You have been the only one who has tried to help me out of several forums. I appreciate it.
I find I get the most out of learning by playing with real examples of what I have learned.
I have done a lot of reading about vbs, done lots of online walk throughs, but I think it's time to buy a book.

Anyway, I did manage to figure out how to get it working, I had to re-write it, but that's fine, it didn't take too long hehe.
So here it is, and now I get to expand on it and learn some more.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body>
<script type="text/vbscript">
Sub ctc_onclick
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("C:/Documents and Settings/test.txt", ForReading)
Do
Dim ab, sel_line, enterquery, test
ab = objTextFile.readLine
sel_line = split(ab, ",")
test = sel_line(0)
enterquery = Document.output_line.whichrecord.value
Loop until test = enterquery
query_line = sel_line
Document.output_line.lineid.Caption = query_line(0)
Document.output_line.month.Caption = query_line(2)
Document.output_line.amount.Caption = query_line(3)
Document.output_line.comments.Caption = query_line(1)
objTextFile.Close
End Sub
</script>
<p>&nbsp;</p>
<form name="output_line">
<table width="100%" border="3" cellspacing="0" cellpadding="0">
   <tr>
     <td width="20%">Entry #</td>
     <td width="20%">month</td>
     <td width="20%">amount</td>
     <td width="20%">comments</td>
   </tr>
   <tr>
     <td>&nbsp;
       <OBJECT ID="lineid" WIDTH=100 HEIGHT=24
 CLASSID="CLSID:978C9E23-D4B0-11CE-BF2D-00AA003F40D0">
         <PARAM NAME="ForeColor" VALUE="0">
         <PARAM NAME="BackColor" VALUE="16777215">
         <PARAM NAME="Caption" VALUE="">
         <PARAM NAME="Size" VALUE="1582;635">
         <PARAM NAME="SpecialEffect" VALUE="2">
         <PARAM NAME="FontHeight" VALUE="200">
         <PARAM NAME="FontCharSet" VALUE="0">
         <PARAM NAME="FontPitchAndFamily" VALUE="2">
         <PARAM NAME="ParagraphAlign" VALUE="2">
         <PARAM NAME="FontWeight" VALUE="0">
       </OBJECT></td>
     <td><OBJECT ID="month" WIDTH=100 HEIGHT=24
 CLASSID="CLSID:978C9E23-D4B0-11CE-BF2D-00AA003F40D0">
         <PARAM NAME="ForeColor" VALUE="0">
         <PARAM NAME="BackColor" VALUE="16777215">
         <PARAM NAME="Caption" VALUE="">
         <PARAM NAME="Size" VALUE="1582;635">
         <PARAM NAME="SpecialEffect" VALUE="2">
         <PARAM NAME="FontHeight" VALUE="200">
         <PARAM NAME="FontCharSet" VALUE="0">
         <PARAM NAME="FontPitchAndFamily" VALUE="2">
         <PARAM NAME="ParagraphAlign" VALUE="2">
         <PARAM NAME="FontWeight" VALUE="0">
       </OBJECT>
     </td>
     <td><OBJECT ID="amount" WIDTH=100 HEIGHT=24
 CLASSID="CLSID:978C9E23-D4B0-11CE-BF2D-00AA003F40D0">
         <PARAM NAME="ForeColor" VALUE="0">
         <PARAM NAME="BackColor" VALUE="16777215">
         <PARAM NAME="Caption" VALUE="">
         <PARAM NAME="Size" VALUE="1582;635">
         <PARAM NAME="SpecialEffect" VALUE="2">
         <PARAM NAME="FontHeight" VALUE="200">
         <PARAM NAME="FontCharSet" VALUE="0">
         <PARAM NAME="FontPitchAndFamily" VALUE="2">
         <PARAM NAME="ParagraphAlign" VALUE="2">
         <PARAM NAME="FontWeight" VALUE="0">
       </OBJECT>
     </td>
     <td>OBJECT ID="comments" WIDTH=100 HEIGHT=24
       CLASSID="CLSID:978C9E23-D4B0-11CE-BF2D-00AA003F40D0">
       <PARAM NAME="ForeColor" VALUE="0">
       <PARAM NAME="BackColor" VALUE="16777215">
       <PARAM NAME="Caption" VALUE="">
       <PARAM NAME="Size" VALUE="1582;635">
       <PARAM NAME="SpecialEffect" VALUE="2">
       <PARAM NAME="FontHeight" VALUE="200">
       <PARAM NAME="FontCharSet" VALUE="0">
       <PARAM NAME="FontPitchAndFamily" VALUE="2">
       <PARAM NAME="ParagraphAlign" VALUE="2">
       <PARAM NAME="FontWeight" VALUE="0">
       </OBJECT>
     </td>
   </tr>
</table>
<input type="text" name="whichrecord" size="5">
<input type="button" id="viewbutton" value="view" name="ctc" >
</form>
</body>
</html>

(in reply to sheepz)
 
 
Post #: 12
 
 RE: passing variables - 9/21/2007 8:20:59 PM   
  sheepz


Posts: 247
Score: 2
Joined: 3/17/2006
From: Riverside the 909s
Status: offline
yeah i know it's really hard when your just stuck on something and just need a little help.  i'm still very new myself, learned a lot from all the admins and members here.  they always seem to find time to help others so people like us can learn and grow.  thanks to those folks that always help and support.  


okie we established that your using an .HTML heres a sample for grabbing user input of string and number:

<HTML>
<HEAD>
<TITLE>Grab user input</TITLE>
<SCRIPT LANGUAGE="vbscript">
Sub strOutput_OnClick
  sValue = frmOutput.strText.Value
  frmOutput.strValue.Value = sValue  '<--- pass value into html
  MsgBox sValue   '<--- Sample msg
End Sub
Sub numOutput_OnClick
  nValue = cint(frmOutput.iNum.Value) '<--- Cint() to ensure input is numeric
  frmOutput.numValue.Value = nValue  '<--- pass value into html
  MsgBox nValue   '<--- Sample msg
End Sub
</SCRIPT>
</HEAD>
<H3>Grab user input</H3>
<FORM NAME="frmOutput">    <!-- Name of FORM, used in reference in vbscript above -->
<table>
  <tr><td>
    Sample String input <input type="text" id="strText" size="15"></td>  <!-- text field -->
  <td>
    <input type="button" value="Display Text" Name="strOutput"></td>
  </tr>
  <tr><td>
    Sample Number input <input type="text" id="iNum" size="15"></td>    <!-- number field --> 
    <td>
   <input type="button" value="Display Number" Name="numOutput"></td>
  </tr>
</table><br>
Textbox for user string input <INPUT TYPE="text" NAME="strValue"><br>  <!-- Display STRING field --> 
Textbox for user number input <INPUT TYPE="text" NAME="numValue">      <!-- Display NUM field -->
</FORM>
</BODY>
</HTML>

(in reply to Tin)
 
 
Post #: 13
 
 RE: passing variables - 9/22/2007 12:19:32 PM   
  Tin

 

Posts: 15
Score: 0
Joined: 8/30/2007
Status: offline
Thanks Sheepz
I'll hang on to that for future reference.

Take care,
Tin

(in reply to sheepz)
 
 
Post #: 14
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> passing variables Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts