...

View Full Version : struggling once more



olpray
01-10-2007, 05:19 PM
i have a small piece of javascript i have written using a prompt, i need to take what is entered into the prompt box and use it in an if statement, can anyone help me?

<html>

<head>

<SCRIPT LANGUAGE = JavaScript>
function CityTimes() {
prompt("Please Input Your City Below","Type Here") ;



</SCRIPT>

<meta http-equiv="Content-Language" content="en-gb">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>City Times</title>
</head>

<body>

<p><u><font size="7"><b>City Times</b></font></u></p>
<p>New York</p>
<p>Paris</p>
<p>Moscow</p>
<p>Beijing</p>
<p>Tokyo</p>
<p>Sydney</p>

<input type = "button" value="Click here to input a city" name="cmdTimes" onclick ="CityTimes() " >

</body>

</html>

anyone?

david_kw
01-10-2007, 06:04 PM
Here is an example of a prompt return value used in an if.



<html>
<head>
<title>City Times</title>
<script type="text/javascript">
function CityTimes() {
var s = prompt("Please Input Your City Below","Paris") ;

var paras = document.getElementsByTagName("p");
for (var i = 0; i < paras.length; i++) {
if (paras[i].innerHTML == s) {
paras[i].style.backgroundColor = "yellow";
} else {
paras[i].style.backgroundColor = "";
}
}
}
</script>
</head>
<body>
<p><u><font size="7"><b>City Times</b></font></u></p>
<p>New York</p>
<p>Paris</p>
<p>Moscow</p>
<p>Beijing</p>
<p>Tokyo</p>
<p>Sydney</p>
<input type="button" value="Click here to input a city" name="cmdTimes" onclick="CityTimes();" />
</body>
</html>


david_kw



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum