/    Sign up×
Community /Pin to ProfileBookmark

One line in netscape 7

I have the below script to change line breaks to ‘^ character in a text area field, but its not working in netscape 7. While it does change a ‘^ to ‘rn’, it won’t change the ‘rn’ to ‘^‘. It seems it is not hitting the second while loop – while (tempx.indexOf(outx)>-1) {

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Transitional//EN”>

<html>
<head>
<title>Untitled</title>

<SCRIPT LANGUAGE=”JavaScript”>
function changeback() {
if (document.NOAServiceLevelInfo.message) {

var entry = document.NOAServiceLevelInfo.message.value;
var out = “^“;
var addd = “rn”;
var temp = “” + entry;

while (temp.indexOf(out)>-1) {
pos= temp.indexOf(out);
temp = “” + (temp.substring(0, pos) + addd +
temp.substring((pos + out.length), temp.length));
}
document.NOAServiceLevelInfo.message.value = temp;
}
}

function change() {
if ( document.NOAServiceLevelInfo.message ) {
alert (“one”);

var entryx = document.NOAServiceLevelInfo.message.value;
outx = “rn”;
addx = “^“;
tempx = “” + entryx;

alert (“two”);

while (tempx.indexOf(outx)>-1) {
alert (“three”);
posx= tempx.indexOf(outx);
tempx = “” + (tempx.substring(0, posx) + addx +
tempx.substring((posx + outx.length), tempx.length));
}
document.NOAServiceLevelInfo.message.value = tempx;
}
}

</SCRIPT>

</head>

<body>

<form action=”” name=”NOAServiceLevelInfo” id=”NOAServiceLevelInfo”>

<input type=hidden name=packit value=””><textarea name=message cols=44 rows=6></textarea>

<input type=”button” value=”change” onclick=”change();”>
<input type=”button” value=”change back” onclick=”changeback();”>

</form>

</body>
</html>

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@NevermoreApr 15.2003 — What exactly are you trying to accomplish? I f you are just trying to keep all of the text on one line, you can use the <nobr> tag.
Copy linkTweet thisAlerts:
@mawoodauthorApr 15.2003 — I am trying to allow users to use the return key (line break) in a text area but changing the value to be a single line string upon submission as the line breaks cause errors in my JSP's. On the confirmation page, the single line string will be displayed with the breaks but the value submitted to the data base will be a single line.
Copy linkTweet thisAlerts:
@FredLabrosseApr 15.2003 — *walkin in wondering why mawood uses netscape*

hey!

*runs out like hell!*
Copy linkTweet thisAlerts:
@mawoodauthorApr 15.2003 — [i]Originally posted by FredLabrosse [/i]

[B]*walkin in wondering why mawood uses netscape*



hey!



*runs out like hell!* [/B]
[/QUOTE]



I..umm...don't. I just have to code for those who do - against my will.
Copy linkTweet thisAlerts:
@mawoodauthorApr 16.2003 — Is this a difficult one? No one knows what I should do here?
×

Success!

Help @mawood spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...