Solved

vbscript, forms, action

Posted on 1998-11-09
20
195 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
 
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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Accessibility and Usability are two concepts that seem to be closely related.  But, too many people seem to have a distorted perception of them. During last five years, those two words have come to the day-to-day work of almost every web developeā€¦
Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmakerā€¦
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

705 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now