Solved

replace text and its hyperlink in a table

Posted on 2012-03-19
6
191 Views
Last Modified: 2012-06-21
hi

i have attached table view being displayed from a source in a webpage. at the bottom of the table is a text that indicates disclaimer (it has its hyperlinks). i need to remove the text and its hyperlink for the following html formatted text:

<div style=text-align:right; border:none><FONT FACE=Arial SIZE=1 COLOR=000000>Quotes delayed at least 15 minutes. Market data provided by Interactive Data.</FONT></div>

how can i do this in javascript or ajax and have it working in IE, Firefox and chrome.
inv.jpg
0
Comment
Question by:eaweb
  • 4
6 Comments
 

Author Comment

by:eaweb
ID: 37739923
i am testing below ajax code but it doesn't work 100 percent.

using (jquery-1.7.1.min.js)

$(document).ready(function() {
      $(":contains('disclaimer'):last", "table").parents("td:first").html("<div style=text-align:right; border:none><FONT FACE=Arial SIZE=1 COLOR=000000>Quotes delayed at least 15 minutes. Market data provided by Interactive Data.</FONT></div>");
      });

without it everthing works fine even in firefox and chrome. with working fine i mean the data is being displayed with the disclaimer text.
when i try to use it to replace the disclaimer text it doesn't work in firefox or chrome and for anthor account it doesn't display the data..
0
 
LVL 20

Expert Comment

by:Proculopsis
ID: 37740967
<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title> - jsFiddle demo</title>
 
  <script type='text/javascript' src='http://code.jquery.com/jquery-1.7.1.js'></script>
 
<style type='text/css'>
    .disclaimer { display: none; }
  </style>
 
<script type='text/javascript'>//<![CDATA[
$(function(){
$('#test').click(function() {
    $("a:contains(disclaimer)").replaceWith($(".disclaimer").toggle());
    $(this).attr({disabled: true});
});
});//]]>  

</script>


</head>
<body>
  <div class="disclaimer" style="text-align:right; border:none;"><FONT FACE=Arial SIZE=1 COLOR=000000>Quotes delayed at least 15 minutes. Market data provided by Interactive Data.</FONT></div>

<input id="test" type="button" value="Test" />

<a href="#">disclaimer</a><img src="http://filedb.experts-exchange.com/incoming/2012/03_w12/561331/inv.jpg" />
 
</body>
</html>
0
 
LVL 22

Assisted Solution

by:Mrunal
Mrunal earned 500 total points
ID: 37740968
Check that if the object you are accessing by:
$(":contains('disclaimer'):last", "table").parents("td:first")
is getting properly.
Something you are getting undefined in this selector.

Can you share your html also so that we can give you exact solution?

If you are getting that object correctly, then instead of directly assigning its html value, first clear its contents then assign html to it.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:eaweb
ID: 37742062
Proculopsis, the table row containing the disclaimer text didn't change.
Please find attached the script i am using. As you will see in the code, the table is being retrieved from another source.
Document2.txt
0
 

Accepted Solution

by:
eaweb earned 0 total points
ID: 37742264
Hi, i found the error. The ajax code was misplaced. It needed to be placed just under the retrieved table containing the disclaimer text. here the solution:

***********************************
<script language="JavaScript" type="text/javascript" src="includes/js/jquery-1.7.1.min.js"></script>

<script language='JavaScript' >
document.write('<table  cellpadding="0" cellspacing="0" align="center" style="border-width: 1px;  border-style: solid; border-color: #CCCCCC;">');
document.write('<tr><td>');
document.write('<table border="0" align="center" >');
document.write('<!-- MarketWatch market summary -->');
document.write('<tr><td>');
document.write('<link rel="stylesheet" href="https://custom.gtm.idmanagedsolutions.com/custom/alliance/ii/alliancestyle.asp?siteid=D33E5570-0390-4BA1-ADE2-0DFC506881F0" type="text/css" media="all"><form method="GET">');
</script>

<script language='JavaScript' > 
function getMWArgs(){

        var args = new Object();                //object for storing param=value pairs
        var query = location.search.substring(1); //grab the text after the '?'
        var pairs = query.split("&");           //create an array of param=value pairs
      var newstring = "";

         for(var i = 0; i < pairs.length; i++){ //loop through the array
                var pos = pairs[x].indexOf('='); //check for an '='
                if (pos == -1) continue; //no '=', skip this array dimention
                var argname = pairs[x].substring(0,pos); //extract parameter name
                //skip parameters that are hard coded in the calling script block
if(argname.toLowerCase() != "siteid" && argname.toLowerCase() != "urlpull" && argname.toLowerCase() != "exstyle"){
                        newstring += pairs[x] + "&"  //concatenate the new string
                }
        }


        return newstring;
}


document.write ('<' + "script language=\"JavaScript\" type=\"text/javascript\" src=\"https://custom.gtm.idmanagedsolutions.com/custom/alliance/ii/dquote.asp?siteid=5F70B991-2B67-4808-940C-8BB73A9D4B54&urlpull=<#itm_text name="INV_URLPULL_ITMVI_BALINQRECEIPT95">&exstyle=t");

if (location.search.toString().indexOf("symb") != -1) {
      if (location.search.toString().indexOf("osymb") == -1) {
      //hit
            //alert("symb but no osymb");      
      } else {
            document.write('&symb=djia&"');
      }
} else {
      document.write('&symb=djia&"');
}

document.write(getMWArgs());
document.write("\">" );

document.write("</");
document.writeln("script>");

$(document).ready(function() {
      $(":contains('disclaimer'):last", "table").parents("td:first").html("<div style=text-align:right; border:none><FONT FACE=Arial SIZE=1 COLOR=000000>Quotes delayed at least 15 minutes. Market data provided by Interactive Data.</FONT></div>");
      });

</script>
0
 

Author Closing Comment

by:eaweb
ID: 37770394
it's how i solved it
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question