[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 207
  • Last Modified:

vbscript, forms, action

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
denam
Asked:
denam
  • 12
  • 8
1 Solution
 
denamAuthor Commented:
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
 
denamAuthor Commented:
the option value for the first selection (Argentina) is wrong in the previous comment.
it should just be "Argentina"
0
 
rajgnCommented:
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
denamAuthor Commented:
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
 
denamAuthor Commented:
btw, the form is saved with a .htm extension.
0
 
rajgnCommented:
Which browser you're using to test this page?
0
 
rajgnCommented:
Which browser you're using to test this page?
0
 
denamAuthor Commented:
btw, the form is saved with a .htm extension.
0
 
denamAuthor Commented:
i'm Netscape navigator 4.05
0
 
rajgnCommented:
No problem, .htm extension is not the reson for your problem
0
 
denamAuthor Commented:
i'm Netscape navigator 4.05
0
 
rajgnCommented:
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
 
denamAuthor Commented:
Thanks rajgn.
0
 
denamAuthor Commented:
is there any good online reference that can show me how to do this in javascript?
thx.
0
 
rajgnCommented:
Just hold on for a sec. I'll be back to you...
0
 
denamAuthor Commented:
is there any good online reference that can show me how to do this in javascript?
thx.
0
 
rajgnCommented:
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
 
denamAuthor Commented:
is there any good online reference that can show me how to do this in javascript?
thx.
0
 
denamAuthor Commented:
wow, thanks.  that's really above and beyond!
0
 
rajgnCommented:
You're welcome...
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 12
  • 8
Tackle projects and never again get stuck behind a technical roadblock.
Join Now