Javascript RegEx: remove all HTML but links - javascript

Any way to easily remove all HTML from text but keep all links? I know how to strip all HTML tags, but can't figure out how to keep just links...
Here's my text:
<table border="0" cellpadding="2" cellspacing="7" style="vertical-align:top;">
<tr>
<td width="80" align="center" valign="top"></td>
<td valign="top" class="j">
<font style="font-size:85%;font-family:arial,sans-serif"><br /></font>
<div style="padding-top:0.8em;">
<font style="font-size:85%;font-family:arial,sans-serif"><img alt="" height="1"
width="1" /></font>
</div>
<div class="lh">
<font style="font-size:85%;font-family:arial,sans-serif"><a href=
"http://news.google.com/news/url?sa=t&fd=R&usg=AFQjCNHlTH-LLUq2nHL30fKdJcA62JseSg&url=http://edition.cnn.com/2011/WORLD/africa/05/13/egypt.suzanne.mubarak/">
<b>Egypt's former first lady said to have suffered a heart attack</b></a><br />
<font size="-1"><b><font color="#6F6F6F">CNN
International</font></b></font><br />
<font size="-1">"Hosni Mubarak was also questioned about his luxury mansion in
Sharm el-Sheikh," al-Gohary <b>said</b>. Last month, the <b>former</b>
president <b>suffered a heart attack</b> during questioning over possible
corruption charges, <b>Egyptian</b> state television reported.
<b>...</b></font><br />
<br />
<a class="p" href=
"http://news.google.com/news/more?gl=us&pz=1&ned=us&ncl=dmv9Cur49MVVXrM">
<font class="p" size="-1"><nobr><b>and
more ยป</b></nobr></font></a></font>
</div>
</td>
</tr>
Thanks

Is this what you want?
function getLinks() {
var table = document.getElementsByTagName('table')[0];
var links = table.getElementsByTagName('a');
for (var i=links.length-1;i>=0;--i) {
table.parentNode.insertBefore(links[i],table.parentNode.firstChild)
}
}

Related

Multiple line text and image display

I am in need to display a Text in two lines with an image on its right side. Something like :
Image
ABCDEFGH Image
(ABC) Image
Image
However my output is making the text come down of the image and that also in a single line:
<div>
<br/>
<br/>
<br/>
<br/>
<img src="images/ecg.jpg" alt="ECG" height="100" width="300" align="middle">
<table cellpadding="0" cellspacing="0" border="0">
<tr class="row1">
<td><b>Electrocardiac Diagram </b></td>
<td><b>(ECG) </b></td>
</tr>
</table>
<br/>
<br/>
</div>
How can I achieve the same?
Right way to do this :
<div style="float:left">
<p><b>Electrocardiac Diagram </b></p>
<p><b>(ECG) </b></p>
</div>
<div style="float:left">
<img src="images/ecg.jpg" alt="ECG" height="100" width="300" align="middle">
</div>
Live Exemple : http://jsfiddle.net/dLZsQ/
Add style='float:right;' to your image like this
<img src="images/ecg.jpg" style='float:right;' alt="ECG" height="100" width="300" align="middle" />
Demo here

Table HTML overflow

I'm trying to make a better looking memberlist for my website. http://www.pimpkings.com/memberlist
<table width="100%" rules="cols" border="1" cellspacing="2" cellpadding="1">
<colgroup span="5" </colgroup>
<tr>
<td class="{memberrow.ROW_CLASS}" td align="center" width="200" valign="top" border="0" cellpadding="0">
<span class="gen"><a class="gen" href="{memberrow.U_VIEWPROFILE}">{memberrow.USERNAME}</a></span>
<div class="avatar mini">{memberrow.AVATAR_IMG}</div>
<align="center" border="0" cellspacing="0" width="200">
<center><font face="verdana" decoration="yes" size="2" color="white">Information</font></center>
<br /><font face="verdana" size="1" color="green">Interest:</font> <br />
<span class="gen">{memberrow.INTERESTS}</span>
<br /><font face="verdana" size="1" color="green">Join Date:</font> <br />
<span class="gensmall">{memberrow.JOINED}</span>
<br /><font face="verdana" size="1" color="green">Last Visited:</font> <br />
<span class="gensmall">{memberrow.LASTVISIT}</span>
<br /><font face="verdana" size="1" color="green">Post Count:</font> <br />
<span class="gen">{memberrow.POSTS}</span>
<align="right" border="0" cellspacing="2" width="200">
<center> <br /><font face="verdana" size="2" color="green">Contact</font><br /></center>
{memberrow.PM_IMG}
{memberrow.WWW_IMG}
</tr>
</td>
</body>
Problem is when I add another
<td>
It makes it duplicate the information I am calling upon. I will actually make the code the way i am talking about so when you visit the site you will see what I am talking about. I just don't want it to duplicate any members information. so basically
Member 2. Member
Member 4. Member
Member 6. Member
Is what I mean
not
1.Member 1.Member
2.Member 2.Member
...
Is there any way possible to do this? I am using a forum website and i have access to the CSS stylesheet and where this code is. Maybe a Javascript code??? Please help asap for the code I am doing is for an open site but is needed for a soon be opened site that is being paid for. Please and thank you everyone.
Also any way of making a background image repeat for the members background table??
I'd Like to have 3 columns made that is calling on the variables listed in the code without repeat.
Thanks again
You shouldn't use tables. Welcome to the world of CSS floats. Here's a shiny new example for you:
HTML
<ul class="tableHold">
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
<li>6</li>
</ul>
CSS
.tableHold {
overflow: auto;
}
.tableHold li {
float: left;
width: 100px;
border: 1px solid black;
}
Here's some more information on how things work.
Here's a fiddle to play with.
HTML
<div class="tableHold">
<div> 1 </div>
<div> 2 </div>
<div> 3 </div>
<div> 4 </div>
<div> 5 </div>
<div> 6 </div>
</div>
CSS
.tableHold {
overflow: auto;
}
.tableHold div {
float: left;
width: 100px;
border: 1px solid black;
}
Try this on http://codebins.com/bin/4ldqpak

Automatically login to site [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I want to be able to log in to a site automatically. For that purpose, i save a copy of login page of that site. Then i enter passsword and user name on this copy in advance. There is a login button on this page. So normally, after typing user name and password, i need to click this button to go to next page. But i want to do this automatically. Here is the related part of the source code:
<html>
<head>
<meta http-equiv="imagetoolbar" content="no">
<link rel="SHORTCUT ICON" href="/favicon.ico">
<SCRIPT>var main=window;</SCRIPT><SCRIPT LANGUAGE="JavaScript" src="http://localhost/_common/cjmaker.js"></SCRIPT>
<title>Login Page</title>
<SCRIPT LANGUAGE="JavaScript"> function openNewBrowserWindow() { newWindow = window.open("http://localhost/_common/lvl5/dologin.html", "subWind", "statusbar,menubar,resizable"); newWindow.focus(); } function getUsername() { return document.getElementById("nameInput").value; } function getPassword() { return document.getElementById("pass").value; } function setFocus() { document.getElementById('nameInput').value == "" ? document.getElementById("nameInput").focus() : document.getElementById("pass").focus(); } </SCRIPT><style type="text/css">
<!--
td { font-family: Arial, Helvetica, sans-serif; font-size: 18px; }
body { font-size:12px; vertical-align:baseline; padding:0; margin:0px; height:1px; font-family:arial;color:#A8A8A8; background-color:#000000;}
.normText { color:#A8A8A8; }
.normTextBold { font-weight:bold; }
.bigText { font-size: 30px; font-weight: bold }
.bigRedText { font-size: 30px; color: #FF0000; font-weight: bold }
.legalTextArea { font-size:10px; color:A8A8A8; background-color:000000}
.smallText { font-size:12px }
-->
</style></head>
<body style="height:100%" SCROLL="NO" onload="setFocus();document.getElementById('loginForm').submit();">
<table border=0 cellpadding=0 cellspacing=0 style="width:100%; height:100%">
<tr height="27px" style="max-height:27px;">
<td valign="bottom" width="14" height="27px"> <img width="14" height="27" src="http://localhost/_common/lvl5/skin/graphics/login/sectionb5.gif"></td>
<td valign="bottom" width="13" height="27px"><img width="13" height="27" src="http://localhost/_common/lvl5/skin/graphics/login/sectionb6.gif"></td>
<td valign="bottom" width="100%" style="position: relative; background-image: url('http://localhost/_common/lvl5/skin/graphics/login/sectionb7.gif'); background-repeat: repeat-x;" height="27px"></td>
<td valign="bottom" width="14" height="27px"> <img width="14" height="27" src="http://localhost/_common/lvl5/skin/graphics/login/sectionb8.gif"></td>
</tr>
<tr>
<td width="10" style="background-image: url('http://localhost/_common/lvl5/skin/graphics/login/sectionc5.gif'); background-repeat: repeat-y;">
</td>
<td COLSPAN="2">
<form id="loginForm" method="post" name='loginForm' action="http://localhost/_common/servlet/lvl5/login?language=en" onsubmit="document.getElementById('pass').value = CJMaker.makeString(document.getElementById('pass').value);" ></form>
<div align="center"><img src="/logo.gif" width="536"></div>
<table border="0" align="center" name="logintable" >
<tr>
<td colspan="3"> </td></tr><tr><td align="center" colspan=3 height="100"><span class="normText"><span class="bigRedText">Dealer Copy</span></span><br><span class="normText"><span class="normRedText">This software is only licensed for internal use by a Dealer for Automated Logic Corporation</span><BR><SPAN class="smallText">Serial Number ( W200500023 )</SPAN></SPAN></span></td>
</tr><tr><td colspan="3"> </td></tr>
<tr>
<td colspan=3 align="center">Please log in</td>
</tr>
<tr>
<td width="50%" align="right">
<div align="right" style="margin-right:10px;">Name:</div>
</td>
<td>
<div align="left">
<input id="nameInput" type="text" value="Administrator" name="name" size="25" maxlength="80" tabindex="1" style="width:175px;">
<script>
if(document.getElementById('nameInput').value == '')
{
document.getElementById('nameInput').focus();
}
</script>
</div>
</td>
<TD rowspan="2" width="50%" align="left">
<div align="left" style="margin-left:10px;">
<input type="submit" id="submit" name="Submit" style="background-color:#A8A8A8" value="Log in" tabindex="2">
</div>
</TD>
</tr>
<tr>
<td>
<div align="right" style="margin-right:10px;">Password:</div>
</td>
<td>
<div align="left">
<input type="password" value="" id="pass" name="pass" autocomplete="off" size="25" maxlength="80" tabindex="1" style="width:175px; ">
<script>
if(document.getElementById('nameInput').value != '')
{
document.getElementById('pass').focus();
}
</script>
</div>
</td>
</tr>
</table>
</td>
<td valign="top" width="14" style="background-image: url('http://localhost/_common/lvl5/skin/graphics/login/sectionc8.gif'); background-repeat: repeat-y">
<span id="actionVbar" style="position:relative; width=100%; height=100%"></span>
</td>
</tr>
<tr height="14px" style="max-height:14px">
<td valign="top"><img width="14" height="14" src="http://localhost/_common/lvl5/skin/graphics/login/sectiond5.gif"></td>
<td COLSPAN="2" valign="top" style="background-image: url('http://localhost/_common/lvl5/skin/graphics/login/sectiond6.gif'); background-repeat: repeat-x; line-height: 14px;" height="14px"> </td>
<td valign="top" height="14px"><img width="14" height="14" src="http://localhost/_common/lvl5/skin/graphics/login/sectiond8.gif"></td>
</tr>
</table><div id="imagecachediv" style="position:absolute; z-index:-10; top:0px; left:0px; visibility:hidden" >
<IMG SRC="http://localhost/_common/lvl5/skin/graphics/actions/acbutton_down_middle.gif">
<IMG SRC="http://localhost/_common/lvl5/skin/graphics/actions/acbutton_down_left.gif">
<IMG SRC="http://localhost/_common/lvl5/skin/graphics/actions/acbutton_down_right.gif">
<IMG SRC="http://localhost/_common/lvl5/skin/graphics/actions/acbutton_up_middle.gif">
<IMG SRC="http://localhost/_common/lvl5/skin/graphics/actions/acbutton_up_left.gif">
<IMG SRC="http://localhost/_common/lvl5/skin/graphics/actions/acbutton_up_right.gif">
<IMG SRC="http://localhost/_common/lvl5/skin/graphics/actions/actionbutton_dn_middle.gif">
<IMG SRC="http://localhost/_common/lvl5/skin/graphics/actions/actionbutton_dn_left.gif">
<IMG SRC="http://localhost/_common/lvl5/skin/graphics/actions/actionbutton_dn_right.gif">
<IMG SRC="http://localhost/_common/lvl5/skin/graphics/actions/actionbutton_up_left.gif">
<IMG SRC="http://localhost/_common/lvl5/skin/graphics/actions/actionbutton_up_middle.gif">
<IMG SRC="http://localhost/_common/lvl5/skin/graphics/actions/actionbutton_up_right.gif">
<IMG SRC="http://localhost/_common/lvl5/skin/graphics/facets/facettab_down_middle.gif">
<IMG SRC="http://localhost/_common/lvl5/skin/graphics/facets/facettab_up_middle.gif">
<IMG SRC="http://localhost/_common/lvl5/skin/graphics/buttons/textbutton_down_middle.gif">
<IMG SRC="http://localhost/_common/lvl5/skin/graphics/buttons/textbutton_up_middle.gif">
<IMG SRC="http://localhost/_common/lvl5/skin/graphics/properties/equip_templates/setpt_graphics/setpointtempindicator.gif">
<IMG SRC="http://localhost/_common/lvl5/skin/graphics/properties/equip_templates/setpt_graphics/setpointheader.gif">
<IMG SRC="http://localhost/_common/lvl5/skin/graphics/properties/equip_templates/setpt_graphics/setpointbody.gif">
<IMG SRC="http://localhost/_common/lvl5/skin/graphics/properties/equip_templates/setpt_graphics/setpointfooter.gif">
<IMG SRC="http://localhost/_common/lvl5/graphics/patterns/uphashes.gif">
<IMG SRC="http://localhost/_common/lvl5/graphics/patterns/horiz.gif">
<IMG SRC="http://localhost/_common/lvl5/graphics/patterns/leftdiagonal.gif">
<IMG SRC="http://localhost/_common/lvl5/graphics/patterns/vert.gif">
<IMG SRC="http://localhost/_common/lvl5/graphics/patterns/tickbackground.gif">
<IMG SRC="http://localhost/_common/lvl5/graphics/patterns/squares.gif">
<IMG SRC="http://localhost/_common/lvl5/graphics/main/de/scheduleticks_12.gif">
<IMG SRC="http://localhost/_common/lvl5/graphics/main/en/scheduleticks_12.gif">
<IMG SRC="http://localhost/_common/lvl5/graphics/main/es/scheduleticks_12.gif">
<IMG SRC="http://localhost/_common/lvl5/graphics/main/fr/scheduleticks_12.gif">
<IMG SRC="http://localhost/_common/lvl5/graphics/main/fr_FR/scheduleticks_12.gif">
<IMG SRC="http://localhost/_common/lvl5/graphics/main/ko/scheduleticks_12.gif">
<IMG SRC="http://localhost/_common/lvl5/graphics/main/ru/scheduleticks_12.gif">
<IMG SRC="http://localhost/_common/lvl5/graphics/main/sv/scheduleticks_12.gif">
<IMG SRC="http://localhost/_common/lvl5/graphics/main/th/scheduleticks_12.gif">
<IMG SRC="http://localhost/_common/lvl5/graphics/main/vi/scheduleticks_12.gif">
<IMG SRC="http://localhost/_common/lvl5/graphics/main/zh/scheduleticks_12.gif">
<IMG SRC="http://localhost/_common/lvl5/graphics/main/zh_TW/scheduleticks_12.gif">
<IMG SRC="http://localhost/_common/lvl5/graphics/main/de/scheduleticks_24.gif">
<IMG SRC="http://localhost/_common/lvl5/graphics/main/en/scheduleticks_24.gif">
<IMG SRC="http://localhost/_common/lvl5/graphics/main/es/scheduleticks_24.gif">
<IMG SRC="http://localhost/_common/lvl5/graphics/main/fr/scheduleticks_24.gif">
<IMG SRC="http://localhost/_common/lvl5/graphics/main/fr_FR/scheduleticks_24.gif">
<IMG SRC="http://localhost/_common/lvl5/graphics/main/ko/scheduleticks_24.gif">
<IMG SRC="http://localhost/_common/lvl5/graphics/main/ru/scheduleticks_24.gif">
<IMG SRC="http://localhost/_common/lvl5/graphics/main/sv/scheduleticks_24.gif">
<IMG SRC="http://localhost/_common/lvl5/graphics/main/th/scheduleticks_24.gif">
<IMG SRC="http://localhost/_common/lvl5/graphics/main/vi/scheduleticks_24.gif">
<IMG SRC="http://localhost/_common/lvl5/graphics/main/zh/scheduleticks_24.gif">
<IMG SRC="http://localhost/_common/lvl5/graphics/main/zh_TW/scheduleticks_24.gif">
<IMG SRC="http://localhost/_common/lvl5/graphics/main/de/schedulefooter_12.gif">
<IMG SRC="http://localhost/_common/lvl5/graphics/main/en/schedulefooter_12.gif">
<IMG SRC="http://localhost/_common/lvl5/graphics/main/es/schedulefooter_12.gif">
<IMG SRC="http://localhost/_common/lvl5/graphics/main/fr/schedulefooter_12.gif">
<IMG SRC="http://localhost/_common/lvl5/graphics/main/fr_FR/schedulefooter_12.gif">
<IMG SRC="http://localhost/_common/lvl5/graphics/main/ko/schedulefooter_12.gif">
<IMG SRC="http://localhost/_common/lvl5/graphics/main/ru/schedulefooter_12.gif">
<IMG SRC="http://localhost/_common/lvl5/graphics/main/sv/schedulefooter_12.gif">
<IMG SRC="http://localhost/_common/lvl5/graphics/main/th/schedulefooter_12.gif">
<IMG SRC="http://localhost/_common/lvl5/graphics/main/vi/schedulefooter_12.gif">
<IMG SRC="http://localhost/_common/lvl5/graphics/main/zh/schedulefooter_12.gif">
<IMG SRC="http://localhost/_common/lvl5/graphics/main/zh_TW/schedulefooter_12.gif">
<IMG SRC="http://localhost/_common/lvl5/graphics/main/de/schedulefooter_24.gif">
<IMG SRC="http://localhost/_common/lvl5/graphics/main/en/schedulefooter_24.gif">
<IMG SRC="http://localhost/_common/lvl5/graphics/main/es/schedulefooter_24.gif">
<IMG SRC="http://localhost/_common/lvl5/graphics/main/fr/schedulefooter_24.gif">
<IMG SRC="http://localhost/_common/lvl5/graphics/main/fr_FR/schedulefooter_24.gif">
<IMG SRC="http://localhost/_common/lvl5/graphics/main/ko/schedulefooter_24.gif">
<IMG SRC="http://localhost/_common/lvl5/graphics/main/ru/schedulefooter_24.gif">
<IMG SRC="http://localhost/_common/lvl5/graphics/main/sv/schedulefooter_24.gif">
<IMG SRC="http://localhost/_common/lvl5/graphics/main/th/schedulefooter_24.gif">
<IMG SRC="http://localhost/_common/lvl5/graphics/main/vi/schedulefooter_24.gif">
<IMG SRC="http://localhost/_common/lvl5/graphics/main/zh/schedulefooter_24.gif">
<IMG SRC="http://localhost/_common/lvl5/graphics/main/zh_TW/schedulefooter_24.gif">
<IMG SRC="http://localhost/_common/lvl5/graphics/main/trpixel.gif">
<IMG SRC="http://localhost/_common/lvl5/skin/graphics/scrollbar/actscrollup.gif">
<IMG SRC="http://localhost/_common/lvl5/skin/graphics/scrollbar/actscrolldown.gif">
<IMG SRC="http://localhost/_common/lvl5/skin/graphics/scrollbar/actscrollleft.gif">
<IMG SRC="http://localhost/_common/lvl5/skin/graphics/scrollbar/actscrollright.gif">
<IMG SRC="http://localhost/_common/lvl5/skin/graphics/scrollbar/navscrollslider.gif">
<IMG SRC="http://localhost/_common/lvl5/skin/graphics/scrollbar/navscrollhchan.gif">
<IMG SRC="http://localhost/_common/lvl5/skin/graphics/scrollbar/navscrollvchan.gif">
<IMG SRC="http://localhost/_common/lvl5/skin/graphics/scrollbar/navscrollup.gif">
<IMG SRC="http://localhost/_common/lvl5/skin/graphics/scrollbar/navscrolldown.gif">
<IMG SRC="http://localhost/_common/lvl5/skin/graphics/scrollbar/navscrollleft.gif">
<IMG SRC="http://localhost/_common/lvl5/skin/graphics/scrollbar/navscrollright.gif">
<IMG SRC="http://localhost/_common/lvl5/graphics/main/propscrollhchan.gif">
<IMG SRC="http://localhost/_common/lvl5/graphics/main/propscrollvchan.gif">
</div>
</body>
</html>
What i tried to do was adding a script such as
<SCRIPT LANGUAGE="JavaScript">document.getElementById('pass').value = CJMaker.makeString(document.getElementById('pass').value;</SCRIPT>
The same code located inside "onsubmit" part of "FORM" block. But it didnt work.
Can you help me with this one , please?
Thanks in advance.
add document.getElementById('loginForm').submit(); in the <body> tag on event onLoad.
eg,
<body onload="document.getElementById('loginForm').submit();">
I solved the problem by simplifying it.
<html>
<title>Login Page</title>
<body onload="document.getElementById('loginForm').submit();">
<form id="loginForm" method="post" name='login' action="http://localhost/_common/servlet/lvl5/login?language=en" onsubmit="document.getElementById('pass').value = CJMaker.makeString(document.getElementById('pass').value);" >
<input id="nameInput" type="text" value="Administrator" name="name" size="25" maxlength="80" tabindex="1" style="width:175px;">
<input type="password" value="" id="pass" name="pass" autocomplete="off" size="25" maxlength="80" tabindex="1" style="width:175px; ">
</form>
</body>
</html>
call this code
$('#nameInput').val('user name');
$('#pass').val('password');
$('#loginForm').submit();
Try above code to login automaticaly. I think it will work.

How to auto check all checkboxes with same name?

I have used checkboxes for checking the mails in my mailing system which is developed in Java.
I want to check all the checkboxes on the click of upper checkbox, but the problem is there that checkboxes are displayed in the the loop according to number of mails retrieved.
Please help me where should i put the javascript code to solve this problem.
The loop code of inbox is given below:
<tr >
<% for(int i=0;i<messageList.size();i++) { message = (Message)messageList.get(i);%>
<td width="10%" height="33" align="left" valign="top" bgcolor="#EEE" >
<!--This link display the full message-->
<input name="Mark_Mail" id="mark_mail" onclick="myfunction(this);" type="checkbox" value="<%=message.getMailId()%>" width="50" height="30" align="top" >
<span id="space1" style="padding:2px"></span>
<!--Check all the Checkboxes-->
<script type="text/javascript">
function checkAll()
{
document.getElementById('mark_mail').checked = "true";
}
</script>
<img src="Images/UnStarred.jpg" height="15" border="0" id="image1" onclick="swapImage()" />
<span id="space1" style="padding:2px"></span>
</td>
<td width="90%" height="33" align="left" colspan="7" valign="bottom" bgcolor="#EEE" >
<!--This link display the full message-->
<a id="link" href="viewMail.jsp?mailId=<%=message.getMailId()%>&isAttach=<%=message.getAttachmentFlag()%>">
<!--Display Sender Address-->
<font color="#000000" size="1"><strong><%=message.getSenderAddress()%></strong></font>
<span id="space1" style="padding:6px"></span>
<!--For Display Message Subject-->
<font color="#000000" size="1"><strong><%=message.getSubject()%></strong></font>
<span id="space1" style="padding:6px"></span>
<!--For Display Attachment Image-->
<%if(message.getAttachmentFlag().equals("1")){%><input type="hidden" name="filename" id="filename" value="<%=message.getFileName()%>" /><input type="hidden" name="filesize" id="filesize" value="<%=message.getFileSize()%> /><img src ="Images/attachment.jpg" style="bgcolor: #EEE" /><%}else{%><span style="padding-left:12px" ></span><%}%>
<span id="space1" style="padding:6px"></span>
<!--For Display Time and Date of messaging-->
<font color="#000000" size="1"><strong><%=message.getTimestamp()%><span style="padding-left:5px"></span><%=message.getDate()%><input type="hidden" name="label" value="<%=message.getLabel()%>"></strong></font>
</a></td>
</tr><% } %>
You need to get the elements by their name, as ID must be unique:
function checkAll() {
var arrMarkMail = document.getElementsByName("mark_mail");
for (var i = 0; i < arrMarkMail.length; i++) {
arrMarkMail[i].checked = true;
}
}
Just place this code in the <head> section of the page.
To call it, have such checkbox wherever you like:
Master: <input type="checkbox" onclick="checkAll();" />
However this better be done by a button:
<button type="button" onclick="checkAll();">Check All</button>

Jquery in Internet Explorer 8, unable to append multiline HTML to existing DIV, works fine in other browsers

This has got me stumped, I am testing my app on IE8 and an AJAX call is being made to the server and it is getting back a return like below. I am then doing an alert to check the output (it matches what I have below) and then it is supposed to append this to a DIV but it always fails to do this. Even if I put an alert past this line of code it still works so its not giving an error it seems, either. I figure there must be some thing with IE8 and multine-line variables or something as I am completely stumped by this, I would greatly appreciate if anyone can help.
What I am calling to append
alert(callbackReturnData)
$("#parent_tabDocumentSearch_displayMessageContents").append(
"<div id='test'>"
+ callbackReturnData + "</div>");
The contents of the callbackReturnData variable (returned from AJAX)
<div class="documentHead">
<div class="col1">
<p>
Sender: <strong><span id="dispayFileContents_sender">V Charles Weldon</span>
</strong>
</p>
<p><div id="div_subject">
Subject: <strong><span id="dispayFileContents_subject">Timesheet Revision</span>
</strong>
</div>
</p>
<p><div id="div_recipients">
Recipient: <strong><span id="dispayFileContents_recipients">Rebecca Torres</span>
</strong>
</div>
</p>
</div>
<div class="col2">
<p>
Date: <strong><span id="dispayFileContents_date"></span>12/22/2000</strong>
Rank: <strong><span id="dispayFileContents_rank"></span> </strong>
</p>
<p>
Time: <strong></strong>
</p>
<p>
Document #: <strong><span id="dispayFileContents_displayCount"></span>
</strong>
</p>
</div>
<div class="col-right">
<div class="prev-btn">
<img onclick="TabDocumentSearch_emailContentsViewNextPrev('prev')"
src="http://witnesstreefiles.s3.amazonaws.com/stable/liquis/images/prev.png"
width="25" />
</div>
<div class="next-btn">
<img onclick="TabDocumentSearch_emailContentsViewNextPrev('next')"
src="http://witnesstreefiles.s3.amazonaws.com/stable/liquis/images/next.png"
width="25" />
</div>
</div>
<div class="clear"></div>
</div>
<div class="documentBody documentBodyScroll">
I'm taking 4 hours vacation today and have updated my previous timesheet to
<br>reflect this. Please see attached.
<br>
<br>
<br>***********
<br>EDRM Enron Email Data Set has been produced in EML, PST and NSF format by ZL Technologies, Inc. This Data Set is licensed under a Creative Commons Attribution 3.0 United States License <http://creativecommons.org/licenses/by/3.0/us/> . To provide attribution, please cite to "ZL Technologies, Inc. (http://www.zlti.com)."
<br>***********
<br>Attachment: AA- Timesheet.12-16-30-00.doc type=application/msword
<br>
</div>
<div class="documentFoot">
<div class="col1">
<p style="margin-top:10px;">
Comment: <input id="tabDocumentSearch_documentCustomComment"
value="
"
name="" type="text" /> <input type=button " class="save button"
value="Save"
onclick="tabDocumentSearch_tabDocuments_updateComment()"></input>
</p>
</div>
<div class="col-right">
<div class="col1" style="margin-right:10px">
<table>
<tr>
<td style="width: 20px;" class="center"><img
src="http://witnesstreefiles.s3.amazonaws.com/stable/liquis/images/hot-btn.png"
width="20">
<div id="radioHolder_h"></div></td>
</td>
<td style="width: 20px;" class="center"><img
src="http://witnesstreefiles.s3.amazonaws.com/stable/liquis/images/priv-btn.png"
width="20">
<div id="radioHolder_p"></div></td>
</td>
<td style="width: 20px;" class="center"><img
src="http://witnesstreefiles.s3.amazonaws.com/stable/liquis/images/resp-btn.png"
width="20">
<div id="radioHolder_r"></div></td>
</td>
<td style="width: 20px;" class="center"><img
src="http://witnesstreefiles.s3.amazonaws.com/stable/liquis/images/cold-btn.png"
width="20">
<div id="radioHolder_c"></div></td>
</td>
<td style="width: 20px;" class="center">
<img src="http://witnesstreefiles.s3.amazonaws.com/stable/liquis/images/custom-btn.png" width="20">
<div id="radioHolder_cust"></div></td>
</td>
<td style="padding-top:18px;" class="center">
<select style='width:150px' class='specialHidden1' id='setCustomTagForDocument' name=''>
<option selected='selected'>Set Custom Tag</option>
<option>Priv - legal</option>
<option>Priv - spouse</option>
<option>Priv - medical</option>
</select>
</td>
</tr>
</table>
</div>
<script type="text/javascript">
$("#setCustomTagForDocument").change(function() {
tabDocumentSearch_setCustomTag()
});
</script>
<div class="prev-btn">
<img onclick="TabDocumentSearch_emailContentsViewNextPrev('prev')"
src="http://witnesstreefiles.s3.amazonaws.com/stable/liquis/images/prev.png"
width="25" />
</div>
<div class="next-btn">
<img onclick="TabDocumentSearch_emailContentsViewNextPrev('next')"
src="http://witnesstreefiles.s3.amazonaws.com/stable/liquis/images/next.png"
width="25" />
</div>
</div>
<div class="clear"></div>
</div>
<div class="clear"></div>
</div>
<script type="text/javascript">
$("#tabDocumentData_documentCustomComment").keydown(function(event) {
if (event.keyCode == 13) {
tabDocumentSearch_tabDocuments_updateComment()
}
})
</script>
I solved a similar jQuery problem that only affected IE. The <br> tags in callbackReturnData may be the culprits (plus any other unclosed tags/invalid HTML). Try closing them like: <br />.
Relevant jQuery( html, [ ownerDocument ] ) documentation:
To ensure cross-platform
compatibility, the snippet must be
well-formed. Tags that can contain
other elements should be paired with a
closing tag... Tags that cannot
contain elements may be quick-closed
or not.
(I know <br> cannot include other elements, but removing this tag fixed the problem. Also it doesn't seem to be an issue with jQuery 1.6/IE9, anymore.)
This is purely a guess but I think jQuery has issues adding html like that. does it work if you go straight javascript?
var d = document.createElement('div');
d.setAttribute('id', 'test');
d.innerHTML = callbackReturnData;
document.getElementById('parent_tabDocumentSearch_displayMessageContents').appendChild(d);
Alternatively, I think you can try something like
var $div = $("<div id='test'>" + callbackReturnData + "</div>");
$("#parent_tabDocumentSearch_displayMessageContents").append($div);
I had an extra closing tag in my appended html that was causing this issue for me. No error from IE, just a failure to add anything to the DOM.

Categories

Resources