SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    Under Construction Poop_Shoot's Avatar
    Join Date
    Jul 2003
    Location
    Sacramento, CA
    Posts
    330
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Returning Line Numbers!

    Hello All, I have the following script!

    Code:
    <html>
    	<head>
    <script language="Javascript">
    function searchDoc(what){
    var found;
    var e=document.getElementById("searchArea").getElementsByTagName("*");
    var el=e.length;
    	for(i=0;i<el;i++){
    	if(e[i].innerText.toLowerCase()==what.toLowerCase()){
    		e[i].style.backgroundColor="yellow";
    		e[i].style.textDecoration="underline";
    		found=true;
    		}
    	}
    	if(!found){
    		alert("not found!");
    	}
    }
    
    </script>
    <style>
    
    </style>
    	</head>
    	<body>
    	<form>
    	<input type="text" name="search">
    	<input type="button" value="search" onclick="searchDoc(this.form.search.value);"> 
    	</form>
    	<div id="searchArea">
    	<font>HELLO</font><br>
    	<font>HOW</font><br>
    	<font>ARE</font><br>
    	<font>YOU</font><br>
    	<font>TODAY</font><br>
    	</div>
    	</body>
    </html>
    And it lead me to wonder if I can return the line number of certain obj, elements, or tags something like this maybe!
    document.getElementById(foo).getElementsByTagName(foo).lineNumber();
    or something along that line! Any help would be great!

  2. #2
    SitePoint Evangelist compwizard's Avatar
    Join Date
    May 2002
    Location
    United States
    Posts
    457
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    why would you need to know the line number?
    Compwizard
    "There are 10 kinds of people in this world -- those who know binary, and those who don't."

  3. #3
    Under Construction Poop_Shoot's Avatar
    Join Date
    Jul 2003
    Location
    Sacramento, CA
    Posts
    330
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    know reason in perticular just good to know things! I know it is used to handle custom javascript exceptions!

  4. #4
    SitePoint Guru Vincent Puglia's Avatar
    Join Date
    Feb 2000
    Location
    where the World once stood
    Posts
    700
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Gee PoopShoot, you've got an awful lot of names

    Although I answered your thread at WebXperts, I'll do so here as well. Search for cr/lf (10/13) and increment a var (lineNum) for each one that's found.

    Vinny
    Where the World Once Stood
    the blades of grass
    cut me still

  5. #5
    Under Construction Poop_Shoot's Avatar
    Join Date
    Jul 2003
    Location
    Sacramento, CA
    Posts
    330
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok I think I should be honest I am Scriptkeeper of codingforums and hairynugs of webxpertz! I wish I could change all my names to one but it is to late!

    As for your advice I dont know if I am just retarded but it does not make sence to me I understand incrementing a lineNum var part! But what the in the world does cr/lf(10/13) mean? Thanks time 4 Coffee


Bookmarks

Posting Permissions

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