Click to See Complete Forum and Search --> : One line in netscape 7


mawood
04-15-2003, 12:31 PM
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 '\r\n', it won't change the '\r\n' 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 = "\r\n";
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 = "\r\n";
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>

Nevermore
04-15-2003, 12:50 PM
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.

mawood
04-15-2003, 01:02 PM
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.

FredLabrosse
04-15-2003, 01:44 PM
*walkin in wondering why mawood uses netscape*

hey!

*runs out like hell!*

mawood
04-15-2003, 01:53 PM
Originally posted by FredLabrosse
*walkin in wondering why mawood uses netscape*

hey!

*runs out like hell!*


I..umm...don't. I just have to code for those who do - against my will.

mawood
04-16-2003, 07:26 AM
Is this a difficult one? No one knows what I should do here?