Hi Gibb,
The only thing I saw was that getAddress2() also needs to be called 'onfocus' because they may tab to the textbox instead of clicking on it.
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<script type='text/javascript'>
window.onload = function()
{
// You can assign event handlers here so you don't
// have to have Javascript mixed with the HTML.
var f2 = document.forms['searchform2'];
f2.onsubmit = liveSearchCatSubmit;
f2.term.onkeypress = liveSearchStart;
f2.term.onclick = getAddress2;
f2.term.onfocus = getAddress2;
}
function getAddress2()
{
var f1 = document.forms['startpointform'];
var f2 = document.forms['searchform2'];
if (!f1.city.value.length || !f1.state.value.length) {
alert('You must provide at least a city and state as a starting point.');
return false;
}
f2.street.value = f1.street.value;
f2.city.value = f1.city.value;
f2.state.value = f1.state.value;
window.status += 'getAddress2, ';///////
return true;
}
function liveSearchCatSubmit()
{
return confirm('liveSearchCatSubmit: return true?');
}
function liveSearchStart()
{
window.status += 'liveSearchStart, ';///////
}
</script>
</head>
<body>
<form name="startpointform" id="startpointform" >
Address:<br />
<input type="text" name="street" size="30" /><br />
City / State<br />
<input type="text" name="city" size="15" />
<input type="text" name="state" size="3" maxlength="2" /><br />
</form>
<form action="" name="searchform2" id="searchform2">
<!--
<form action="http://cross-browser.com/test/echo.php" name="searchform2" id="searchform2" onsubmit="return liveSearchCatSubmit()">
-->
<!-- I changed the name value from 'name' to 'term'. Use whatever you want,
but I suggest not using a value that is the same as an attribute name. -->
<input type="text" name="term" id="livesearch" maxlength="35" />
<!--
<input type="text" onfocus="getAddress2()" onclick="getAddress2()" name="term" id="livesearch" onkeypress="liveSearchStart()" maxlength="35" />
-->
<!-- VARIABLES -->
<input type="hidden" name="id" value="" />
<input name='street' type='hidden' />
<input name='city' type='hidden' />
<input name='state' type='hidden' />
<!-- END VARIABLES -->
</form>
</body>
</html>
Bookmarks