Forum Moderators: open

Message Too Old, No Replies

initializing a textarea value

works with IE6 does not work with NS 6.1

         

damovand

8:51 pm on Mar 27, 2003 (gmt 0)

10+ Year Member



Hello everyone,

I would appreciate any help on this problem. I have a JavaScript that opens a window and initializes the value of a textarea element. It works in IE6 but does not work in NS 6.1. The script is a text book variety but I must be doing something wrong or not compatible with NS, because when I open the page in NS the new window opens without any value in the textarea element. It seems that this statement:
<<<<<<< snip >>>>>>>>
helpWindow.document.inputForm.exhibit.value = field.value;
<<<<< snip >>>>>>>
doesn't work. The following is more of the script. What am I doing wrong can someone please help?

var helpWindow = 0;
function openWindow(url,title, field )
{
if(helpWindow){

}else{
helpWindow = window.open(url, 'title', 'scrollbars,resizable,width=350,height=300');
}
helpWindow.document.inputForm.exhibit.value = field.value;
helpWindow.focus();
alert ("Done ");
}

thanks in advance

DrDoc

10:32 pm on Mar 27, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome [webmasterworld.com] to Webmaster World!

Give the element an ID, and use something like this:

if(document.getElementById) {
// For newer browsers...
document.getElementById('the_ID').value = "blah";
}
else if (document.all) {
// For older IE...
document.all['the_ID'].value = "blah";
}

damovand

12:55 am on Mar 28, 2003 (gmt 0)

10+ Year Member



Hello DrDoc,

NS 6.1 still does not work. I'm wondering if the problem is with textarea element. I bet if this field was not textarea it would work, but then it would not suite my purpose.

DrDoc

1:09 am on Mar 28, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It should work in NN6. I used something similar as late as yesterday.

Did you change the field.value part too, which assigns the value to the textarea?

damovand

1:31 am on Mar 28, 2003 (gmt 0)

10+ Year Member



Actually, I didn't do anything to field.value, that is just a <input> field of type hidden as shown below

<input type="hidden" name=exhibit value='#include ....'>

The value is large piece of text which I'm trying to transfer to the textarea element on a second window so that the user can edit it.

The following is the call that is supposed to open the second window and initialize it.

<input type=radio name=exh_type value=”EMBEDDED “ checked onclick='JavaScript: openWindow("html/getExhibit.htm", "Supplemental Information",input.exhibit);'>

This is really puzzling to me but I'll keep probing it and crossing my fingers that something will fix it.

Thanks

caine

1:34 am on Mar 28, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



be careful that you have not written jscript rather than javascript, it can lead to problems as you have described.

tedster

2:54 am on Mar 28, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I notice you have smart quotes around the value attribute in your posted code snippet. If they are copy/pasted from your actual code, you should change them to straight quotes.

HocusPocus

9:41 am on Mar 28, 2003 (gmt 0)

10+ Year Member



Looks like Netscape doesn't recognise the Form element of the opened window until the form is fully loaded. Seems fair enough. Here's my fudgy solution that's been tested and works in NN4, NN6 and IE 6.

<HTML>
<script>
var helpWindow = 0;
var isWindowLoaded = 0;
var string ="";

function openWindow(url,title, field)
{
if(helpWindow){
x=0;
}else{
helpWindow = window.open(url, 'title', 'scrollbars,resizable,width=350,height=300');
}
string=field.value +"";
helpWindow.focus();
isWindowLoaded = setTimeout('checkWindowLoaded()', 250);
}

function checkWindowLoaded()
{
isWindowLoaded=clearInterval();
if (typeof(helpWindow.document.inputForm)!="undefined")
{
helpWindow.document.inputForm.exhibit.value = string;
}
else
{
isWindowLoaded = setTimeout('checkWindowLoaded()', 250);
}
}
</script>
<FORM name=input>
<input type="hidden" name=exhibit value='TEST TEXT'>

<input type=radio name=exh_type value=”EMBEDDED“ checked onclick='JavaScript: openWindow("open.htm", "Supplemental Information",input.exhibit);'>
</form>
</HTML>

After getting a working solution, I think it best not to use it. I would post the contents of the element to the new window and use Perl, instead of JavaScript, to parse the contents.

-Mark

damovand

3:36 pm on Mar 28, 2003 (gmt 0)

10+ Year Member



Thank you everyone for your comments and guidance.

After reading your suggestions and especially Mark’s remark at the end, I have to conclude that there is no way to safely initialize a form element through JavaScript that will work for NN. I’m going to have to do it through server side programming.

Thanks again for all your help.