Solved

ASP redirect from a combo box without submitting form and using pagename.asp?variable="var" where var is the value in the combo box.

Posted on 2004-08-03
2
1,372 Views
Last Modified: 2011-10-03
Hi folks, hoping someone can help me out.

I have a simple asp page News.asp, which contains a form; frmNews, with a combo box on it, cmbNews.

The combo box contains numerical values, (at the moment 0,1,2). These values represent 'old' (and the 'current') pages of news items for the site. The plan is to be able to select a page number eg "1" from the combo box and be 'instantly' 'forwarded' there as follows: News.asp?page="1"

its actually a redirection to the same page (news.asp) where the page variable is re-queried and the page created according to this number when the page loads. Because the total number of pages at any time will be unknown, it is not possible to put the addresses of the pages into the combo box as follows:

<option value = "http://....news.asp?page="1"> 1 </option>

the current number of pages is calculated (using entries in an SQL database table) as the page is created. I also do not want to submit the form and request the combo box value on a seperate script and then redirect back to the original page - i would rather do everything from the parent page if i can; my server is rather slow at the moment and im trying to avoid un-necessary postings.

I think i need to use javascript to obtain the combo box selected value 'onchange' 'on the fly' so to speak without submitting the form - trouble is my JS sucks, and i am unsure of how to:

a.) obtain the selected value of the combo box
b.) use the value to formulate the addresss of the page to redirect to:

var1 = "News.asp?page="
and
var2 = "1" <---- the combo box value (obtained directly from cmbNews)

with ASP its easy - response.redirect var1 & var2.... etc

c.) actually do the redirection (window.location=...? something like that?)

can anyone give me any help at all on this? im really stumped :(

Its kinda urgent, so ANY help at all is more than appreciated. Thanks ppl!

~C~




0
Comment
Question by:AW_Chris
2 Comments
 
LVL 22

Accepted Solution

by:
neeraj523 earned 500 total points
ID: 11712513
Hello

What i understand.. you want to redirect your page based on selection form your combo

Sample script:

=======================================================
<SCRIPT Language="JAVASCRIPT">
function getPage(theCombo)
{
      if(theCombo.value != "")
      {
            location.href="<%=Request.ServerVariables("URL")%>?page=" + theCombo.value
      }      
}
</SCRIPT>
  <select size="1" name="myCombo" OnChange="getPage(this)">
  <option value="">---Select---</option>
  <option value="1">Value1</option>
  <option value="2">Value2</option>
  </select>
=======================================================

make sense ??

neeraj523
0
 

Author Comment

by:AW_Chris
ID: 11712575
Worked a treat, after a bit of fiddling with object names etc :) the points are yours!

Many many thanks, ive learnt a lot about integrating JS and ASP from that little snippet!

Cheers,

~C~
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

895 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

13 Experts available now in Live!

Get 1:1 Help Now