Hi VZRon,
One thing to keep in mind is that Javascript isn't immediately aware of any HTML element, even if you give that element a NAME or ID attribute. So in the Rpt8027URL function, the string that you're concatenating is not made up of the values of your <select> elements, but rather it's made up of Javascript variables that have the same name that you're declaring on the fly.
Here's one way that you can get the values of the <select> elements into Javascript variables.
Code:
function Rpt8027URL {
var rptDay = document.getElementsByName("Rpt8027Day")[0].value;
var rptMonth = document.getElementsByName("Rpt8027Month")[0].value;
var rptArea = document.getElementsByName("Rpt8027Area")[0].value;
var Rpt8027URL = "http://xyz.com/ncvo8027/2008-" +rptMonth+ "-" +rptDay+ "." +rptArea+ ".ncvd8027.html";
alert ("You are going to be redirected to " + Rpt8027URL);
window.location(Rpt8027URL);
}
In this code, we declared the variables rptDay, rptMonth, and rptArea. The document.getElementsByName function returns an array of HTML elements with a specific NAME attribute. The [0] that comes after it means we want to work with the 0th element (the very first element in that array) and the .value retrieves the value property of that element.
More often, you'll see Javascript code that uses the document.getElementById function. This returns a single HTML element that has an ID attribute set. It saves you from have to using square brackets to specify a particular element. In your HTML, you'd use <select size="1" id="Rpt8027Month">
Finally notice the window.location() function at the end. This is simply redirects the user to the new URL. You don't need to return any value because the submit button's "onclick" handler wouldn't do anything with it anyway.  Since we're using window.location to do the redirection instead <form action="...">, you don't actually need the FORM element at all in your HTML.
|