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 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Dec 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    javascript ignored

    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.

  • #2
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by lhancoc
    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 ...
    *keep it simple (TM)

  • #3
    New to the CF scene
    Join Date
    Dec 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    javascript ignored

    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

  • #4
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #5
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by lhancoc
    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.


    Quote Originally Posted by lhancoc
    Anyway, here is the javascript that I used:

    Code:
    <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.
    *keep it simple (TM)

  • #6
    New to the CF scene
    Join Date
    Dec 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    javascript ignored

    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....


  •  

    Posting Permissions

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