Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Basics
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old June 1st, 2010, 10:01 AM
Authorized User
Join Date: Feb 2006
Posts: 63
Thanks: 1
Thanked 0 Times in 0 Posts
Send a message via Yahoo to Hannibal
Default How to Refresh asp page,when user selects a value in dropdownbox

I have 2 asp pages - "Home" and "College". The college.asp page is available inside the Home page. So the Home page, has the form element, and the college.asp does not have form element.
The college.asp is inside an iframe of the first page.

I have a dropdown in the college.asp page. There are 3 options in the dropdown, i want to refresh the page, when the user selects the data.
As the college.asp page does not have form element, how to submit the page?
I have tried this, In the college.asp, I have the following:

<select style="width: 140px" name="RptType"  onchange="javascript:changeType(this.options[this.options.selectedIndex].value)"
       <option value="overall" id="seloverall" selected>Overall</option>
       <option value="Pure" id="selpure">Pure</option>
       <option value="Impure" id="selimpure">Impure</option>
<input id=hdnType Type="Hidden" value="overall" name=hdnType /> 
function changeRptType(StrDropdown)
 document.getElementById("hdnType").value =  StrDropdown;  
// Server side script starts
 Dim RadioValue1
 set RadioValue1 = Request.Form("hdnType")
 strSQL = "sp_getAllData '" & RadioValue1 & "'"
 Set rstAllData = Server.CreateObject("ADODB.Recordset")
 Set rstAllData = objConn.ExecuteSQL (strSQL)
I know that inorder to use Request.Form, the page has to be submitted, But how do i submit the page, when there is no form element.

Thank you

Last edited by Hannibal; June 2nd, 2010 at 12:40 AM..
Old June 2nd, 2010, 07:24 PM
Friend of Wrox
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts

It's not legal HTML to have form elements without <form>...</form>, so your iframe code is illegal.

Why do you not want it to have a <form>??

And why in the world do you copy the selected value to a hidden field???

I both the <select> and the <input type=hidden> were in the same <form>, then in the ASP code the values of
would be *IDENTICAL*. You hidden field is serving no useful purpose that I can see.
Old June 2nd, 2010, 07:28 PM
Friend of Wrox
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts

In short, why not just do:
<form method="post">
<select style="width: 140px" name="RptType"  onchange="this.form.submit();">
       <option selected>--choose one--</option>
When you omit the action= from a <form>, it submits the page back to itself.

You'd then change your ASP code to use
Dim RadioValue1
RadioValue1 = Request.Form("RptType")
And I just notice that you were doing
set RadioValue1 = Request.Form("hdnType")
NO! The set there is INCORRECT.

(And I also got rid of the invalid id='s in your <option> tags!)
(And since the value= in our <option>s were the same as the text, the value= was also unnecessary.)
(Finally, ONCHANGE only triggers is the user *MAKES* a change, which means that with your code the user would never trigger and "Overall" selection. So I changed the default <option> so a user can choose "Overall".)

Last edited by Old Pedant; June 2nd, 2010 at 07:31 PM..

Similar Threads
Thread Thread Starter Forum Replies Last Post
auto-refresh page with asp? nlicata Classic ASP Basics 4 October 6th, 2015 01:52 PM
Preventing page refresh from asp.net button hericles ASP.NET 1.0 and 1.1 Professional 2 October 8th, 2008 04:29 PM
Refresh Page when User Clicks on Back Button testsubject Visual Studio 2005 1 June 26th, 2006 03:46 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.