Solved

vbscript, forms, action

Posted on 1998-11-09
20
199 Views
Last Modified: 2013-12-25
I'm trying to set the action in a form using a select.
I've stolen an example right out of the book, but my
script fails.  What am I doing wrong?
0
Comment
Question by:denam
  • 12
  • 8
20 Comments
 
LVL 1

Author Comment

by:denam
ID: 1856255
Here's my form.  When someone selects a country, I want to go to a file
under a directory for that country.
===============================================================
<html>
<head>
<title></title>
<SCRIPT Language = "VBScript">
<! --
Sub submitform()
  Dim f
  Dim sUrl
  set f = Document.frmMain
  sUrl = "&#34/private/membership/" & sWhereToGo.Value & "/default.asp&#34"
  f.Method = "Post"
  f.Action = sUrl
  f.submit
end sub
-->
</script>

<!--#include file="/private/includes/header1.txt"-->
<blockquote>
<p><font color="#408080"><strong><big>Member's Area</big></strong></font></p>

<form name="frmMain">
    <select>
      <option value="membersarea/default.htm">Argentina</option>
      <option value="Austrailia">Australia</option>
      <option value="Austria">Austria</option>
      <option value="Barbados">Barbados</option>
      <option value="Belgium">Belgium</option>
      <option value="Bermuda">Bermuda</option>
      <option value="Canada">Canada</option>
      <option value="Cayman Islands">Cayman Islands</option>
      <option value="Channel Islands">Channel Islands</option>
      <option value="Chile">Chile</option>
      <option value="Denmark">Denmark</option>
      <option value="England">England</option>
      <option value="Hong Kong">Hong Kong</option>
      <option value="Italy">Italy</option>
      <option value="Japan">Japan</option>
      <option value="Liechtenstein">Liechtenstein</option>
      <option value="Mexico">Mexico</option>
      <option value="Monaco">Monaco</option>
      <option value="Scotland">Scotland</option>
      <option value="South Africa">South Africa</option>
      <option value="Sweden">Sweden</option>
      <option value="Switzerland">Switzerland</option>
      <option value="The Netherlands">The Netherlands</option>
      <option value="U.S.A.">U.S.A.</option>
    </select><input type=Button OnClick=submitform value="Go"></p>
  </form>
</blockquote>
<!--#include file="/private/includes/footer1.txt"-->
</body>
</html>

0
 
LVL 1

Author Comment

by:denam
ID: 1856256
the option value for the first selection (Argentina) is wrong in the previous comment.
it should just be "Argentina"
0
 
LVL 1

Expert Comment

by:rajgn
ID: 1856257
I don't see any form element named 'sWhereToGo' in the code you posted, which was used in setting the Action in VBScript. This might be the reason for the failure. It might be the name of the SELECT you're using. So, give that name to the SELECT and see.
0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
LVL 1

Author Comment

by:denam
ID: 1856258
the error i get is:

JavaScript Error: line 68:
submitform is not defined.

and, my apologies, i copied the wrong example into the comment box.  It should have
been:

<html>
<head>
<title>TIAETL Membership</title>
<SCRIPT Language = "VBScript">
<! --
Sub submitform()
  Dim f
  Dim sUrl
  set f = Document.frmMain
  sUrl = "&#34/private/membership/" & f.WhereToGo.Value & "/default.asp&#34"
  f.Method = "Post"
  f.Action = sUrl
  f.submit
end sub
-->
</script>

<!--#include file="/private/includes/header1.txt"-->
<blockquote>
<p><font color="#408080"><strong><big>Member's Area</big></strong></font></p>

<form name="frmMain">
    <select name="WhereToGo">
      <option value="Argentina">Argentina</option>
      <option value="Austrailia">Australia</option>
      <option value="Austria">Austria</option>
      <option value="Barbados">Barbados</option>
      <option value="Belgium">Belgium</option>
      <option value="Bermuda">Bermuda</option>
      <option value="Canada">Canada</option>
      <option value="Cayman Islands">Cayman Islands</option>
      <option value="Channel Islands">Channel Islands</option>
      <option value="Chile">Chile</option>
      <option value="Denmark">Denmark</option>
      <option value="England">England</option>
      <option value="Hong Kong">Hong Kong</option>
      <option value="Italy">Italy</option>
      <option value="Japan">Japan</option>
      <option value="Liechtenstein">Liechtenstein</option>
      <option value="Mexico">Mexico</option>
      <option value="Monaco">Monaco</option>
      <option value="Scotland">Scotland</option>
      <option value="South Africa">South Africa</option>
      <option value="Sweden">Sweden</option>
      <option value="Switzerland">Switzerland</option>
      <option value="The Netherlands">The Netherlands</option>
      <option value="U.S.A.">U.S.A.</option>
    </select><input type=Button OnClick=submitform value="Go"></p>
  </form>
</blockquote>
<!--#include file="/private/includes/footer1.txt"-->
</body>
</html>

0
 
LVL 1

Author Comment

by:denam
ID: 1856259
btw, the form is saved with a .htm extension.
0
 
LVL 1

Expert Comment

by:rajgn
ID: 1856260
Which browser you're using to test this page?
0
 
LVL 1

Expert Comment

by:rajgn
ID: 1856261
Which browser you're using to test this page?
0
 
LVL 1

Author Comment

by:denam
ID: 1856262
btw, the form is saved with a .htm extension.
0
 
LVL 1

Author Comment

by:denam
ID: 1856263
i'm Netscape navigator 4.05
0
 
LVL 1

Expert Comment

by:rajgn
ID: 1856264
No problem, .htm extension is not the reson for your problem
0
 
LVL 1

Author Comment

by:denam
ID: 1856265
i'm Netscape navigator 4.05
0
 
LVL 1

Accepted Solution

by:
rajgn earned 50 total points
ID: 1856266
Oops! I expected it. VB Client side scripting works only in IE. Try the same file in IE, it should work. If you want to run the same script in NS also then you've to script it in JavaScript/JScript.
0
 
LVL 1

Author Comment

by:denam
ID: 1856267
Thanks rajgn.
0
 
LVL 1

Author Comment

by:denam
ID: 1856268
is there any good online reference that can show me how to do this in javascript?
thx.
0
 
LVL 1

Expert Comment

by:rajgn
ID: 1856269
Just hold on for a sec. I'll be back to you...
0
 
LVL 1

Author Comment

by:denam
ID: 1856270
is there any good online reference that can show me how to do this in javascript?
thx.
0
 
LVL 1

Expert Comment

by:rajgn
ID: 1856271
Have a look at:
http://developer.netscape.com/tech/javascript/resources.html 
for various JavaScript resources. Hope you like it. Here I'm writing the same function in JavaScript, for you. Try it out. If you've any probs. can get back to me.

<SCRIPT Language = "JavaScript">
       function submitform() {
         var sUrl
         sUrl = "&#34/private/membership/" + sWhereToGo.Value + "/default.asp&#34"
         Document.frmMain.Method = "Post"
         Document.frmMain.Action = sUrl
         Document.frmMain.submit()
 }
       </script>

make a change in button's code as follows:

onClick="submitform()"
0
 
LVL 1

Author Comment

by:denam
ID: 1856272
is there any good online reference that can show me how to do this in javascript?
thx.
0
 
LVL 1

Author Comment

by:denam
ID: 1856273
wow, thanks.  that's really above and beyond!
0
 
LVL 1

Expert Comment

by:rajgn
ID: 1856274
You're welcome...
0

Featured Post

Independent Software Vendors: 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!

Question has a verified solution.

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

Because your company can’t afford for you to make SEO mistakes, you’ll want to ensure you’re taking the right steps each and every time you post a new piece of content. This list of optimization do’s and don’ts can help you become an SEO wizard.
FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

697 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