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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

loading string into textarea-bizaar occurance

Status
Not open for further replies.

Tracey

Programmer
Oct 16, 2000
690
NZ
hi there

I have a bizaar thing here, where code which should work doesnt, unless i pop an alert() into the function
here is an example, with a html file (relevent only):

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
	<head>
		
		
		<SCRIPT language="JavaScript" src="testz.js"></SCRIPT>
	</head>
	<body language="javascript" onload="returnwindow_onload()">

<TEXTAREA language="javascript" id="Textarea2" style="OVERFLOW: hidden; BACKGROUND-COLOR: whitesmoke"
						disabled onscroll="return Textarea2_onscroll()" name="Textarea2" rows="12" readOnly cols="3"></TEXTAREA></div></td>
				<TD><div id="griddiv2"><TEXTAREA language="javascript" id="Textarea1" onscroll="return Textarea1_onscroll()" name="Textarea1"
						rows="12" cols="10"></TEXTAREA>
<INPUT language="javascript" id="cmdReset" title="Clear the Calculator" style="BACKGROUND-COLOR: #abc81e"
						onclick="return cmdReset_onclick()" type="button" value="   Reset   " name="cmdReset">
</body>
</html>

The javascript file (relevent functions only):

Code:
function Textarea1_onscroll() {
	window.document.getElementById("Textarea2").scrollTop=window.document.getElementById("Textarea1").scrollTop;
}

function Textarea2_onscroll() {
	window.document.getElementById("Textarea1").scrollTop=window.document.getElementById("Textarea2").scrollTop;
}

function window_onload() {
	if(navigator.appName.toLowerCase().indexOf("explorer")>0){
		window.document.getElementById("Textarea2").style.visibility='visible';
		window.document.getElementById("Textarea2").value=strVals;
	}
	else{
		window.document.getElementById("Textarea2").style.visibility='hidden';
	}
	
	// populate the sample selector list
	var strVals='';
	for (i = 1; i < 201; i++) {
		if(i==200)
			strVals=strVals + i;
		else
			strVals=strVals + i + '\r\n';
	}
	window.document.getElementById("Textarea2").value=strVals;
}

function cmdReset_onclick(){
	window.document.getElementById("Textarea1").value='';
	var strVals='';
	window.document.getElementById("Textarea2").value='';

	for (i = 1; i < 201; i++) {
		if(i==200)
			strVals=strVals + i;
		else
			strVals=strVals + i + '\r\n';
	}
//alert("loaded strVals =" + strVals);
	window.document.getElementById("Textarea2").value=strVals;
}

input numbers into the large text box until the top text box scrolls down, so the top number is not 1.

click the reset button. this should clear textarea 1 and reset textarea2 to have 1 at the top.

doesnt work? so uncomment the alert("strVals") line.

now, one you close the alert box, it works. How weird.

anyone care to speculate a remedy? (leaving a popup alert is not an option)

Tracey
Remember... True happiness is not getting what you want...

Its wanting what you have got!
 
oh well never mind. the answer to my problem was right in front of me. I set window.document.getElementById("Textarea2").scrollTop = 0; so is not a problem now.

Tracey
Remember... True happiness is not getting what you want...

Its wanting what you have got!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top