Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascript parser/Find command?

Status
Not open for further replies.

DLLHell

Programmer
May 9, 2003
69
0
0
US
Is there a Javascript command that will do a "find" of a variable within a text field? ex: find "lnkEdit" in a field that has "grid_lnkEdit" and return "lnkEdit" ?
 
you can use match():

Code:
<!DOCTYPE HTML PUBLIC
	&quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;
	&quot;[URL unfurl="true"]http://www.w3.org/TR/html4/loose.dtd&quot;>[/URL]
<html>
	<head>
		<title>match</title>
		<script type=&quot;text/javascript&quot;>
			function find(el) {
				var ta = el.form.ta;
				var result = ta.value.match(el.value);
				
				if (!result)
					alert(el.value + &quot; not found&quot;);
				else
					alert(&quot;Matched &quot; + result);
			}
		</script>
	</head>

	<body>
		<form>
			<textarea name=&quot;ta&quot;>here is some text</textarea>
			<br/>
			<input type=&quot;text&quot; name=&quot;q&quot; />
			<input type=&quot;button&quot; value=&quot;find&quot; onclick=&quot;find(this.form.q);&quot; />
		</form>
	</body>
</html>

=========================================================
-jeff
try { succeed(); } catch(E) { tryAgain(); }
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top