Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
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
Medium Priority
?
1,385 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
[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
2 Comments
 
LVL 22

Accepted Solution

by:
neeraj523 earned 2000 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

Question has a verified solution.

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

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…
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…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

688 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