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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

734 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