Click here to Skip to main content
15,883,705 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How to send ahref value to another page in html
--------------------------------------------

hi frnds,

I have 2 HTML pages,

here i want to send value from first page to 2nd page, when the ahref links clicks.

such as....

1st page.
=========



2nd page
========
It should display as :

Selected Country : Egypt

Please can you help me, how to do this. This is HTML Project only (HTML WEBPAGES)

Thanks.
Posted
Comments
Sergey Alexandrovich Kryukov 14-Sep-14 11:44am    
Please define this notion: "send".
—SA
Member239258 14-Sep-14 11:53am    
Please can you help me.
Thanks.

1 solution

In your first html page you have link like this

HTML
<ul><li><a href="SelectedCountry.htm">Egypt</a></li></ul>


change it to something like this
HTML
<ul><li><a href="SelectedCountry.htm?country=Egypt">Egypt</a></li></ul>


In "SelectedCountry.htm" you will need to write a javascript like the below one to get the value of country.

JavaScript
<script language="javascript">
function getCountry()
{
	var country = new String(window.location);
	index = country.indexOf("=")+1;
	countryName = country.substring(index);
	document.write("Selected Country : "+countryName);
}
getCountry()
</script>

Hope I understood what you meant in a correct manner.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900