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,370 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

708 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

12 Experts available now in Live!

Get 1:1 Help Now