• 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!
0
mpulse24
Asked:
mpulse24
  • 2
1 Solution
 
hexagon47Commented:
something like this?

<html>
<head>
<title>title</title>
<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";
   }
</script>
</head>
<body>
<form name="myform"><select id="definer" onchange="showYearFile()">
<option value="2003">2003</option>
<option value="2002">2002</option>
<option value="2001">2001</option>
</select></form>
<a href="" id="firstLInk">go</a>
   </body>
</html>

tell me if I am on the right track
0
 
hhammashCommented:
Hi,

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">
  <p>
  <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>
  </select></p>
  <%
Dim VarLoc
varLoc=request.form("Year")
varPage="News-"
varExt=".htm"
varDest=varPage+varLoc+varExt
%>
<a href=<%=varDest%>>Go to Page</a>



Regards
hhammash
0
 
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!
0
 
hhammashCommented:
Hi mpulse24,

You are most welcome

hhammash
0

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