...

View Full Version : javascript ignored



lhancoc
12-09-2004, 03:04 PM
I have a javascript that allows you to type into a text box (VB.NET) and it will bring up the closest item in a dropdown list. It works on my localhost machine, but not on the internet. I cannot figure out why my javascript is being ignored. I use IE 6. I have tried it on 4 machines, both in and out of the office.

jbot
12-09-2004, 03:19 PM
I cannot figure out why my javascript is being ignored. I use IE 6. I have tried it on 4 machines, both in and out of the office.

well, are there any JS errors? do these machines have XP/SP2 installed on them?

how can we help you if you won't post any JS - do you think we've been blessed with psychic abilities or something?

be a good lad, and upload the relevant code ... ;)

lhancoc
12-09-2004, 04:43 PM
The reason I didn't include the code is because I didn't think it was relevant. I suspect the problem to be a .NET configuration thing with javascript. (Like, do you change <% @ Page LANGUAGE="vb" to <% @ Page LANGUAGE="jscript" at the top of the html page? ) It works in localhost both ways. We do not have a production server to test on, so I have to have it uploaded by someone else and test it actually online. Anyway, here is the javascript that I used:
<SCRIPT language="JavaScript">
function findText(finder_textbox, finder_selectbox,cnt)
{
var searchStr = finder_textbox.value;
var myExp = new RegExp(("^" + searchStr), "i");
var foundResult = false;
var i=0;
while ((foundResult = false) || (i < finder_selectbox.length))
{
if( myExp.test(finder_selectbox.options[i].text))
{
finder_selectbox.options[i].selected = true;
foundResult = true;
i = cnt; //make this the length of the list + 1
}
i++;

}
}</SCRIPT>
And here is the vb code:
Dim strcnt As String = CStr(Session("TitleCount"))
txtPlat.Attributes.Add("onKeyUp", "javascript:findText (this,ddlPlatTitle," & strcnt & ")")

Please resist the offensive remarks and just try to help.
Thank you,
Linda

Willy Duitt
12-09-2004, 05:03 PM
Can you confirm the file is being called when the page loads...
You should post a link so we can look at this ourselves...

.....Willy

jbot
12-09-2004, 05:07 PM
The reason I didn't include the code is because I didn't think it was relevant. I suspect the problem to be a .NET configuration thing with javascript. (Like, do you change <% @ Page LANGUAGE="vb" to <% @ Page LANGUAGE="jscript" at the top of the html page? )

It works in localhost both ways. We do not have a production server to test on, so I have to have it uploaded by someone else and test it actually online.


hi Linda,

first off, your serverside config is irrelevant to me, since it shouldn't effect how the clientside JS performs, only wot data it receives.




Anyway, here is the javascript that I used:



<SCRIPT language="JavaScript">
function findText(finder_textbox, finder_selectbox,cnt)
{
var searchStr = finder_textbox.value;
var myExp = new RegExp(("^" + searchStr), "i");
var foundResult = false;
var i=0;
while ((foundResult = false) || (i < finder_selectbox.length))
{
if( myExp.test(finder_selectbox.options[i].text))
{
finder_selectbox.options[i].selected = true;
foundResult = true;
i = cnt; //make this the length of the list + 1
}
i++;

}
}</SCRIPT>



your JS code looks fine. but how do you call it - let's see the HTML for that part?! my first suspicion is that you haven't passed the correct object reference to the function. also, wot JS errors are you getting, and in which browser have you tested this?

btw: sorry for calling you a lad, linda, so used to dealing with blokes on here. hope you were offended.

lhancoc
12-09-2004, 06:03 PM
To Willy Duitt: I can't give the site today because we are removing it and putting the old program out there in preparation for a process review meeting. However, I checked the view source and the javascript code is being downloaded.

To jbot: There is no HTML to call it. I call it from the code behind using the attributes.Add:
Dim strcnt As String = CStr(Session("TitleCount"))
txtPlat.Attributes.Add("onKeyUp", "findText(this,ddlPlatTitle," & strcnt & ")")

strcnt is the count of the records + 1
ddlPlatTitle is the dropdown list
findText is the name of the javascript function

Thanks....



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum