You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jack Lauman <jl...@nwcascades.com> on 2004/11/24 05:33:02 UTC

JavaScript/JSP Question

I'm using the following JavaScript to create lists of restaurants by 
Location and Cuisine.
Is there a way to modify the script to accept a value for the restaurant 
name that would
be similar to a %LIKE% function in MySQL when the user hits the submit 
button?

Thanks,

Jack

<script language="JavaScript">
<!--
function MM_jumpMenu(targ,selObj,restore, field){ //v3.0
   
eval(targ+".location='http://www.mydomain.com/restaurant/filter.jsp?field="+field+"&value="+selObj.options[selObj.selectedIndex].value+"'"); 

 if (restore) selObj.selectedIndex=0;
}
//-->
</script>

<><form name="selectLocation" method="get" 
location="http://www.mydomain.com/restaurant/filter.jsp">
<input type="hidden" name="field" value="city">
<select name="location" size="1" 
onChange="MM_jumpMenu('parent',this,0,'city')">




---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: JavaScript/JSP Question

Posted by Andoni <an...@eurokom.ie>.
Hi,

Yes, there is a way. It is not related to Tomcat in any way but...

what you need to use is "string".indexOf("string2")

So, take the value of the current item in the combo box and see if it
contains the string you are searching for using the indexOf() method. This
is a JavaScript issue though so I suggest if you have further problems you
try addressing comp.lang.JavaScript (available from Google).

If the indexOf() method does not find the substring it will return -1 if it
does, it will return it's index.

HTH

Andoni.

----- Original Message ----- 
From: "Jack Lauman" <jl...@nwcascades.com>
Newsgroups: gmane.comp.jakarta.tomcat.user
Sent: Wednesday, November 24, 2004 4:33 AM
Subject: JavaScript/JSP Question


> I'm using the following JavaScript to create lists of restaurants by
> Location and Cuisine.
> Is there a way to modify the script to accept a value for the restaurant
> name that would
> be similar to a %LIKE% function in MySQL when the user hits the submit
> button?
>
> Thanks,
>
> Jack
>
> <script language="JavaScript">
> <!--
> function MM_jumpMenu(targ,selObj,restore, field){ //v3.0
>
>
eval(targ+".location='http://www.mydomain.com/restaurant/filter.jsp?field="+
field+"&value="+selObj.options[selObj.selectedIndex].value+"'");
>
>  if (restore) selObj.selectedIndex=0;
> }
> //-->
> </script>
>
> <><form name="selectLocation" method="get"
> location="http://www.mydomain.com/restaurant/filter.jsp">
> <input type="hidden" name="field" value="city">
> <select name="location" size="1"
> onChange="MM_jumpMenu('parent',this,0,'city')">


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: [OT] Re: JavaScript/JSP Question

Posted by er...@swapsimple.com.
On Wed, Nov 24, 2004 at 07:11:31AM -0500, Ben Souther wrote:
> This question is not tomcat specific so I'm marking [OT].
> 
> I believe Javascript has the same startsWith/endsWith string
> functionality that Java has.  
> You should be able to simulate that pretty easily.

	js also has full regular expression support through the RegExp class
and the String.match function.   Although that's might be a more difficult
choice for exactly emulating the database LIKE function as all the other
regexp features would need to be escaped.

eric

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


[OT] Re: JavaScript/JSP Question

Posted by Ben Souther <bs...@fwdco.com>.
This question is not tomcat specific so I'm marking [OT].

I believe Javascript has the same startsWith/endsWith string
functionality that Java has.  
You should be able to simulate that pretty easily.





On Tue, 2004-11-23 at 23:33, Jack Lauman wrote:
> I'm using the following JavaScript to create lists of restaurants by 
> Location and Cuisine.
> Is there a way to modify the script to accept a value for the restaurant 
> name that would
> be similar to a %LIKE% function in MySQL when the user hits the submit 
> button?
> 
> Thanks,
> 
> Jack
> 
> <script language="JavaScript">
> <!--
> function MM_jumpMenu(targ,selObj,restore, field){ //v3.0
>    
> eval(targ+".location='http://www.mydomain.com/restaurant/filter.jsp?field="+field+"&value="+selObj.options[selObj.selectedIndex].value+"'");
> 
>  if (restore) selObj.selectedIndex=0;
> }
> //-->
> </script>
> 
> <><form name="selectLocation" method="get" 
> location="http://www.mydomain.com/restaurant/filter.jsp">
> <input type="hidden" name="field" value="city">
> <select name="location" size="1" 
> onChange="MM_jumpMenu('parent',this,0,'city')">
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org