...

View Full Version : Need to get InnerHTML Javascript



lor2000
09-30-2008, 07:03 AM
Javascript example!

I need to get Document InnerHTML on my webpage into a string



My Guess? below
Var Message= INNERHMTL ?? then split it with "/"



here's what's on my webpage

First Name/last Name

Ben/Porter
Mat/Cyber
Dave/Norton

split first and last name with "/" sign

thank for any help

rangana
09-30-2008, 07:57 AM
<script type="text/javascript">
window.onload=function(){
var el=document.getElementById('content');
var remBr=el.innerHTML.split(/<br>/); // Split when br tag is found
for(var i=0;i<remBr.length;i++)
{
remBr[i]=remBr[i].replace(/\s/g,''); // Remove trailing spaes
var fLname=remBr[i].split(/\//); // Split when "/" is found
alert('First Name: '+fLname[0]+'\nLast Name: '+fLname[1]);
}
}
</script>
<p id="content">
Ben/Porter<br>
Mat/Cyber<br>
Dave/Norton
</p>

lor2000
09-30-2008, 10:22 AM
rangana
:thumbsup:Thanks Thats worked for me :thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum