Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Not Over-writing Characters

Status
Not open for further replies.

MLR777

Technical User
Aug 28, 2008
5
0
0
CA
Hello: For the final result, I want the whole STRING (ab_cd_efg_h) to appear in the yellow DIV box. How do I prevent the destruction of the current CHARACTER when the new CHARACTER is created ? I use the ALERT box so you can see the creation and destruction of the CHARACTERs in the yellow DIV box. Thank-You, MLR777

<html>
<head>
<title>replace Method</title>
<script language="javascript" type="text/javascript">
window.onload=triggerMLR1;
function triggerMLR1()
{
var inputMLR = "ab*cd*efg*h";

for (var i=0; i<inputMLR.length; i++)
{
afterReplaceMLR=inputMLR.replace("*", "_");
document.getElementById("idMLR").innerHTML=afterReplaceMLR;
alert(afterReplaceMLR);
}
}
</script>
</head>

<body style="font-family : arial; font-weight : bold;">
<hr />
<div id="idMLR" style="width : 300px; height : 10px; background-color : #ffff00; padding-bottom : 10px; padding-right : 3px; padding-left : 3px; padding-top : 2px; border : 1px solid #000000;">
</div>
<hr />
original STRING: ab*cd*efg*h
<br />
desired STRING: ab_cd_efg_h
</body>
</html>
 
Hello: I was given s solution to this Script (by Rangana). originally I had an = Operator. This Script needs a += Operator as follows ... innerHTML+=afterReplaceMLR;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top