Click to See Complete Forum and Search --> : Referencing Parent Window


skarphace
12-16-2003, 10:24 PM
Ok, I am new to Javascript but it seems a lot like php syntax, except for variables... My problem is referencing the parent window. The goal is to have a form with a link. The link will popup a new window with a list of users, this list will be links. These links, should, change the value of the username box in the parent window. The script below returns an error of "sendBack is not defined" and is in the new window with the user list.

<script type="javascript">
<!--

var usernm=" ";

function sendBack(usernm) {

opener.document.testform.user.value=usernm;
return true;

}

//-->
</script>

<a href="javascript:sendBack('[username]')">[username]</a>


Any help would be appreciated. I'm very stuck.

fredmv
12-16-2003, 10:42 PM
Welcome to the forums.

Interestingly enough, your problem is actually related to HTML; not JavaScript. In your <script> tag, you must specify the content type for the scripting language when using the type attribute, as opposed to the name of the scripting language like with the language attribute. Therefore, your <script> tag should look like this:<script type="text/javascript">

Kor
12-17-2003, 05:48 AM
<script language="JavaScript"> should be enough
or even simply
<script> must do the job

skarphace
12-17-2003, 07:18 AM
Thanks guys. I feel really stupid but it's ok. My mind was set on the details for hours instead of just looking at the general mistakes. Thanks again.