sjgrodriguez
Posts: 26
|
Posted: 11/16/2009, 11:50 AM |
|
Hi there.
Im using a search for with a listbox that contains a list a Cities. Once the search button is pressed, i want the form to open a new asp page that contains the value of the listbox (the city selected, of course).
For example, the main page, where the search form is located is:
http://www.example.com
And if the city "Seville" is selected, i want the asp to redirect to :
http://www.example.com/Seville.asp
Could you please help me???
THANKS IN ADVANCE,
Sergio
|
|
|
andrewi
Posts: 162
|
Posted: 11/16/2009, 4:12 PM |
|
This is code I use for a link, rather than a button. But it might be a start.
This is the html for the link - note the added onclick event.
<a href="http://www.example.com" id="controlId" onclick="JavaScript: return showCity(this);">Show City</a>
And here is the Javascript for the showCity(controlReference) function. You'll need to replace the "CitiesComboBox" string with the Id that Codecharge gives to your Cities combobox/list.
function showCity(ctl)
{
var cityName= document.getElementById("CitiesComboBox").value;
if (cityName == "")
{
alert("please select a city");
return false;
} else
{
ctl.href = "http://www.example.com/" + cityName + ".asp";
}
return;
}
So, when you click the link, this function checks the selected value of the combobox. If it's blank (nothing selected) you get an alert. If not, it builds a URL with the cityName at the end, and puts it in the link's href property.
To make this work for a button rather than a link, you could try replacing "ctl.href" with "window.location.href " and replace the final "return" with "return false"
|
|
|
sjgrodriguez
Posts: 26
|
Posted: 11/19/2009, 11:13 AM |
|
Hey THANKS A LOT ! It worked perfectly. Both ones, with a link and with a button.
THANKS AGAIN. YOU SAVED ME DUDE
Sergio
|
|
|
|