Go Premium for a chance to win a PS4. Enter to Win

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

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

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…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Integration Management Part 2
Suggested Courses
Course of the Month7 days, 21 hours left to enroll

824 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