Solved

VBScript and CGI?

Posted on 1997-05-03
3
571 Views
Last Modified: 2013-12-25
Here is a code fragment of a CGI script written in Visual Basic.
I'm trying to use HTML controls and embedded VBScript to combine the data
(integer) entered into a text box by the user with a choice (string) that
user has selected from a list box and place it into a second text box.
So far I've had no luck getting this to work.
The error message is:  Object required   "Accounts"
Perhaps a better question is: Can you use embedded VBS in a CGI script?


Send ("<INPUT TYPE= ""Text"" NAME=""Balance""  SIZE=""30"">")
Send ("<SELECT NAME=""Accounts"" SIZE=""8"">")
Send ("<INPUT TYPE= ""Text"" NAME=""Total"" SIZE=""45"">")

Send ("<INPUT TYPE=""Button"" NAME=""BTN"" VALUE=""Enter"">")

Send ("<Script Language=VBScript>")
Send ("Sub BTN_OnClick")
Send ("Total.Value =  Accounts.Value & Balance.Value")
Send ("End Sub")
Send ("</Script>")

Thanks
Tom
0
Comment
Question by:thomas73
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 5

Accepted Solution

by:
icd earned 100 total points
ID: 1827985
There really is no reason why any cgi generated HTML should behave any differently to pure HTML. (Although I do remember having some very subtle differences I don't think they will be affecting you).

The approach I would take when writing a CGI that generated HTML, especially where there is embedded script, is to first create a  'dummy' HTML file which has the required content. In your case this would be:-

<INPUT TYPE= "Text" NAME="Balance" SIZE="30">
<SELECT NAME="Accounts" SIZE="8">
<INPUT TYPE= "Text" NAME="Total" SIZE="45">

<INPUT TYPE="Button" NAME="BTN" VALUE="Enter">
<Script Language=VBScript>
  Sub BTN_OnClick
    Total.Value = Accounts.Value & Balance.Value
  End Sub
</Script>

Having tested this and getting it to work you can then look to 'cgi' it. In this way you don't end up testing everything together.

I suspect the problem will be found to not be the cgi but instead be the VBScript. In any case the problem will be easier to spot.

0
 

Author Comment

by:thomas73
ID: 1827986
Thank you for your response.
In my original posting. I did not make it clear that I had included the "Option Value" statements
in the <SELECT> tag. For example:
 <SELECT NAME="Accounts">
<OPTION VALUE="Individual Retirement Account">Individual Retirement Account
<OPTION VALUE="Qualified Retirement Plan">Qualified Retirement Plan
<OPTION VALUE="Individual">Individual
</SELECT>
I just wanted to clear this up and not have you waste your time considering a potential problem that did not exist.

I did as you suggested and removed the CGI 'SEND' statements from the HTML in order to isolate the problem. To narrow the possibilities further, I removed the reference to the "Accounts" Object (the List box) in the VBS Sub procedure, leaving the procedure to read; (Total.Value=Balance.Value). The code works properly in this fashion, transferring the value of the "Balance" text box to the "Total" text box.
Progress!
However, If the Sub procedure is written to include the "Accounts" Object and concatenate the values from the "Balance" text box and the "Accounts" List box; (Total.Value=Accounts.Value & Balance.Value), an error code results stating; "Object does not  support this property or method: "Accounts.Value".

This is were the problem seems to lie. Which attribute of the <SELECT> tag holds the users selection, NAME or VALUE? I have two books on VBScript and HTML that give me two different answers.
I guess you're the tie breaker.

Thanks
Tom

0
 
LVL 5

Expert Comment

by:icd
ID: 1827987
Ah. It becomes clear.

The SELECT object does not have a value. It does have a 'selectedIndex' however. In Javascript to get the value of a SELECT object you would use the following:-

Accounts.options[Accounts.options.selectedIndex].value

I don't have the details for VBScript but I expect it will be very similar (if not identical).

0

Featured Post

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Powershell  and PSExec = Password failure 5 26
SSRS - Powershell 7 80
debug scriptblock parameters in powershell script 2 48
Scripting 4 33
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question