...

View Full Version : 2nd part of code is ignored



h8ids
05-01-2007, 08:19 PM
Calling the this function from "form99", which is located on another page.

The code:


function resultChooser(form99){
if (form99.searchstring != "")
{
form99.action="searchBool.php";
}
else
{
form99.action="searchBool_all.php";
}
}

I know the function is being acted upon. But only the first half of the If... Else statement seems to be recognized.

The default value of the textfield is null. So it should call the "searchBool_all.php" page if nothing is entered into the textfield.

Form code:


<form method="POST" name="form99" onsubmit="resultChooser(this);">
<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" value=""></td>
</tr>
</table>
<div style="position: absolute; left: 60px; top: 80px; width:255px;>
<input type="submit" value="Submit" name="B1">
<input type="reset" value="Reset" name="B2">
</div>
</form>

nikkiH
05-01-2007, 08:27 PM
form99.searchstring.value is the value. The other is the object reference.

h8ids
05-01-2007, 08:49 PM
Please correct me if I'm wrong. I think I'm interpreting this correctly.


//function name referencing "form99"
function resultChooser(form99){

//Checking the value of searchstring which is located in form99
if (form99.searchstring != "")

//If a value ISN'T equal to null goto object - searchBool.php
{
form99.action="searchBool.php";
}

//If a value IS equal to null goto object - searchBool_all.php
else
{
form99.action="searchBool_all.php";
}
}

nikkiH
05-01-2007, 09:29 PM
More like...



function resultChooser(form99){
if (form99.searchstring.value != "")
{
form99.action="searchBool.php";
}
else
{
form99.action="searchBool_all.php";
}
}

h8ids
05-01-2007, 09:39 PM
oh drat.

Thanks again!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum