Jump to content

[SOLVED] search won't work with txtbox!?


husin

Recommended Posts

hey again people, this site is awesome! anyways, i have this code and everything is working except one thing. if you pay attention to the function displayNamesL(), i am trying to make it so that what ever letter you type in the textbox, it will search that when i click the "search" button. the button before that works perfectly. i am getting this error code:

 

line 16,

char 5,

document.frmSearch.txtLetter.value; is null or not an object,

code 0.

i made a comment for line 16 so u don't have to go searchn for it.

 

so if you guys can figure this, much appreciated :)!

 

		<html>
<head>
	<title>AJAX Simple Demo</title>
	<script type="text/javascript">
		function displayNames()
		{
			var myHTTP = new XMLHttpRequest();
			myHTTP.open("GET", "display.php?search=r", false);
			myHTTP.send(null);
			var response = myHTTP.responseText;
			document.getElementById("display_table").innerHTML = myHTTP.responseText;
		}

		function displayNamesL()
		{
			var letter = "search=" + line //line16//document.frmSearch.txtLetter.value;
			var myHTTP = new XMLHttpRequest();
			myHTTP.open("GET", "display.php?letter", false);
			myHTTP.send(null);
			var response = myHTTP.responseText;
			document.getElementById("display_table").innerHTML = myHTTP.responseText;
		}
	</script>
</head>
<body>
	<form name="frmSearch" method="get" action="">

	<p><label>Click to see which names start with "R".</label></p></br>
	<p><input type="button" value="Names - 'R'" onclick="displayNames()" /></p></br>
	<p><label>Or type in a letter of your choice.</label></p></br>
	<p><input type="button" value="Search" onclick="displayNamesL()" /></p></br>
	<p><input type="text" value="" name="Letter" /></p>
	</p>

		<span id="display_table">
		</span>
	</form>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/167059-solved-search-wont-work-with-txtbox/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.