• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 159
  • Last Modified:

A little text manipulation (ASCII values)

Hope the title is not misleading -

I have a drop-down box that I use to select a year.
I would like to have other buttons or icons on the page that call up different pages based on the year selected.

In other words, say there are buttons called "NEWS", "PHOTOGRAPH", and "INFO" next to the drop-down box for the year.

The user first selects a year (which I already have calling up another page when SUBMIT is pressed).
Then if the user wants to see news on that year, he/she clicks the NEWS button. Or the PHOTOGRAPH button or INFO.

So behind the scenes, the drop-down form has a variable named 'Year'.
How can I take the value of 'Year' and combine it with other text in the other buttons?

For example: Pressing NEWS would take the value of 'Year' + a filename literal entered in the button form such that pressing it would call up a page using the combined text.

So I am basically building a new text string from different points.
In a formula (from other languages) it might look like this:
Webpage = "news-" + Year + ".htm"

So if the year selected is 2003, the result of Webpage = "news-2003.htm"
I could then retrieve that particular page.

It is probably simple HTML code so excuse the ignorance - thanks in advance!
  • 2
1 Solution
something like this?

<script type="text/javascript">
   function showYearFile()
    selectedYear = document.getElementById('definer').options[document.getElementById('definer').selectedIndex].value;
    alert("news-" + selectedYear + ".htm");
    document.getElementById('firstLink').href = "news-" + selectedYear + ".htm";
<form name="myform"><select id="definer" onchange="showYearFile()">
<option value="2003">2003</option>
<option value="2002">2002</option>
<option value="2001">2001</option>
<a href="" id="firstLInk">go</a>

tell me if I am on the right track

In the Select tag you have OnChange.
The options should be there with you
Now add the code under the </Select> in your page
This code is for one link which is the year.

<form method="POST" action="GotoYear.asp" name="form1">
  <select size="1" name="Year" onChange=form1.submit()>
  <option value="2001">2001</option>
  <option value="2002">2002</option>
  <option value="2003">2003</option>
  <option value="2004">2004</option>
  <option value="2005">2005</option>
  <option value="2006">2006</option>
Dim VarLoc
<a href=<%=varDest%>>Go to Page</a>

mpulse24Author Commented:
That did it.
I also like the Onchange feature. I was getting a little annoyed with that ugly "SUBMIT" button.
Thanks for the quick response!
Hi mpulse24,

You are most welcome


Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now