h8ids
05-01-2007, 04:16 PM
Trying to direct a form to another page based upon textfield value.
Hoping to avoid using the "Action" command in the "Form" description. I want the code to figure out if the textfield "searchstring" is being utilized.
The "Submit" button has an "onClick" command for function "resultChooser()".
I don't see what I'm missing.
Form Page:
<html>
<head>
<script src="javascript.js"></script>
</head>
<body>
<form method="POST" name="form99">Search using partial criteria.
<table>
<tr>
<td>Searching by:</td>
<td>Insert search criteria. (Leave blank to view all records.)</td>
</tr>
<tr>
<td>Course title</td>
<td><input type="text" name="searchstring"></td>
</tr>
</table>
<div style="position: absolute; left: 60px; top: 80px; width:255px;>
<input type="submit" value="Submit" name="B1" onClick="resultChooser()">
<input type="reset" value="Reset" name="B2">
</div>
</form>
</body>
</html>
Javascript page:
//Boolean search results chooser
function resultChooser(){
if (document.form99.searchstring != '')
{
window.location="searchBool.php";
} else {
window.location="searchBool_all.php";
}
}
Using Firefox Firebug plugin for testing.
It doesn't show any errors. And it confirms that the called function, located in the javascript.js page, is being reached.
Presently, the page only reloads itself and clears any data in the textfield.
Hoping to avoid using the "Action" command in the "Form" description. I want the code to figure out if the textfield "searchstring" is being utilized.
The "Submit" button has an "onClick" command for function "resultChooser()".
I don't see what I'm missing.
Form Page:
<html>
<head>
<script src="javascript.js"></script>
</head>
<body>
<form method="POST" name="form99">Search using partial criteria.
<table>
<tr>
<td>Searching by:</td>
<td>Insert search criteria. (Leave blank to view all records.)</td>
</tr>
<tr>
<td>Course title</td>
<td><input type="text" name="searchstring"></td>
</tr>
</table>
<div style="position: absolute; left: 60px; top: 80px; width:255px;>
<input type="submit" value="Submit" name="B1" onClick="resultChooser()">
<input type="reset" value="Reset" name="B2">
</div>
</form>
</body>
</html>
Javascript page:
//Boolean search results chooser
function resultChooser(){
if (document.form99.searchstring != '')
{
window.location="searchBool.php";
} else {
window.location="searchBool_all.php";
}
}
Using Firefox Firebug plugin for testing.
It doesn't show any errors. And it confirms that the called function, located in the javascript.js page, is being reached.
Presently, the page only reloads itself and clears any data in the textfield.