Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Jan 2006
    Posts
    251
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question 2nd part of code is ignored

    Calling the this function from "form99", which is located on another page.

    The code:
    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:
    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>

  • #2
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    form99.searchstring.value is the value. The other is the object reference.

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/

  • #3
    Regular Coder
    Join Date
    Jan 2006
    Posts
    251
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Please correct me if I'm wrong. I think I'm interpreting this correctly.
    Code:
    //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";
    		}
    	}

  • #4
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    More like...

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

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/

  • #5
    Regular Coder
    Join Date
    Jan 2006
    Posts
    251
    Thanks
    0
    Thanked 0 Times in 0 Posts
    oh drat.

    Thanks again!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •