SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2006
    Posts
    89
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Rendering Dynamic Values To Page

    I have a Link Checker function(). It is potentially a large array - sometimes over 50 links. I am using the match() method to find links that do not fit our criteria. (Example: two ??'s after .asp). In the first test I have encounterd two matches, one at position 24 and one at position 33. In this example I am tring to have these two matches render on a HTML page. I cannot have <span> tags numbering up into the 50's as far as id="" is concerned. Can some tell me how I can have these matches render on the page? Her is the code I am using:

    Code:
    	<script language="javascript" type="text/javascript">
    	function getLinks()
    	{
    		var sHTML = document.getElementById("HTML").value;
    		
    		var all_links = sHTML.match(/http\:\/\/[^\"]+/g);
    		var Double_qMark = new Array();
    		var Double_qMarkLink = new Array();
    		for (var i = 0; i < all_links.length; i++)
    		{
    			var link = all_links[i];
    			if (link.match(/\?\?/))
    			{
    				Double_qMarkLink[i] = [i]+" "+link;
    				Double_qMark[i] = link.match(/\?\?/);
    			}
    		}
    		
    		if (Double_qMark)
    		{
    			var len = Double_qMark.length;
    			for (var x = 0; x < len; x++)
    			{
    				if (Double_qMark[x])
    				{
    					alert(Double_qMarkLink[x]);
    					document.getElementById("Double_qMark1").style.cssText = "display:inline;";
    					document.getElementById("Double_qMark1").innerHTML = "<font color=red"+Double_qMark[x]+"</font><br><br>";
    					document.getElementById("Double_qMarkLink1").style.cssText = "display:inline;";
    					document.getElementById("Double_qMarkLink1").innerHTML = "<font color=red"+Double_qMarkLink[x]+"</font><br><br>";
    					document.getElementById("Double_qMark2").style.cssText = "display:inline;";
    					document.getElementById("Double_qMark2").innerHTML = "<font color=red"+Double_qMark[x]+"</font><br><br>";
    					document.getElementById("Double_qMarkLink2").style.cssText = "display:inline;";
    					document.getElementById("Double_qMarkLink2").innerHTML = "<font color=red"+Double_qMarkLink[x]+"</font><br><br>";
    				}
    			}
    		}
    	}
    	window.onload = getLinks;
    	</script>
    I know that this can be accomplished. I just cannot wrap my head around a solution. Any help would be greatly appreciated.

  2. #2
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Without seeing part of sHTML I can't test it. I really don't understand what you want, but here's a guess...
    Code:
        for (var i = 0, j = 0; i < all_links.length; i++)
        {
          var link = all_links[i];
          if (link.match(/\?\?/))
          {
            Double_qMarkLink[j] = link; // you had a syntax error here
            Double_qMark[j] = link.match(/\?\?/);
            ++j;
          }
        }


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
  •