?
Solved

vbscript, forms, action

Posted on 1998-11-09
20
Medium Priority
?
203 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
[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
  • 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
Learn by Doing. Anytime. Anywhere.

Do you like to learn by doing?
Our labs and exercises give you the chance to do just that: Learn by performing actions on real environments.

Hands-on, scenario-based labs give you experience on real environments provided by us so you don't have to worry about breaking anything.

 
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 150 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

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

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

Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
CTAs encourage people to do something specific to show interest in your company, product or service. Keep reading to learn why CTAs should always be thought of as extremely important, albeit small, sections of websites.
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.
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
Suggested Courses

762 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