Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Dec 2006
    Posts
    41
    Thanks
    6
    Thanked 0 Times in 0 Posts

    reference the opener

    hey guyz....this is regardin referencin the opener.....i mean..am tryin to populate a textbox in parent using child window......i got it all worked out....but when am tryin the add one more form it does'nt work..can anyone tell me y its not workin....am addin the html codes below...plz chk that and lemme know what is wrong.............

    parent.html........
    <SCRIPT LANGUAGE="JavaScript">
    <!--

    function showList() {
    sList = window.open("stocklist.html", "list", "width=150,height=210");
    }

    function remLink() {
    if (window.sList && window.sList.open && !window.sList.closed)
    window.sList.opener = null;
    }

    // -->
    </SCRIPT><FORM NAME="stockForm">Enter your favorite tech stock:
    <INPUT TYPE="text" NAME="stockBox" SIZE="10" VALUE="">
    <INPUT TYPE="button" VALUE="list" onClick="showList()">
    </FORM>
    child window....(stockList.html)
    <SCRIPT LANGUAGE="JavaScript">
    <!--

    function pick(symbol) {
    if (window.opener && !window.opener.closed)
    window.opener.document.stockForm.stockBox.value = symbol;
    window.close();
    }

    // -->
    </SCRIPT>
    </HEAD>
    <BODY>
    <TABLE BORDER="1" CELLSPACING="0" CELLPADDING="5">
    <TR BGCOLOR="#cccccc"><TD><B>NYSE</B></TD><TD><B>NASDAQ</B></TD></TR>
    <TR><TD><A HREF="javascriptick('AOL')">AOL</A></TD>
    <TD><A HREF="javascriptick('CSCO')">CSCO</A></TD></TR>
    <TR><TD><A HREF="javascriptick('CPQ')">CPQ</A></TD>
    <TD><A HREF="javascriptick('INTC')">INTC</A></TD></TR>
    <TR><TD><A HREF="javascriptick('NOK')">NOK</A></TD>
    <TD><A HREF="javascriptick('SUNW')">SUNW</A></TD></TR>
    <TR><TD><A HREF="javascriptick('LU')">LU</A></TD>
    <TD><A HREF="javascriptick('AMZN')">AMZN</A></TD></TR>
    <TR><TD><A HREF="javascriptick('T')">T</A></TD>
    <TD><A HREF="javascriptick('MSFT')">MSFT</A></TD></TR>
    </TABLE>
    </BODY>
    i tried renamin all the field names and form names ,,,but am gettin to work with the 1st form,but 2nd form is not workin....plz lemme know what i have to change in order to get this workin.....thnx.........

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    Here's one possiblity

    PHP Code:
    <SCRIPT type="text/javascript">
    <!--

    function 
    showList(n) {
    num=n
    sList 
    window.open("stocklist.html""list""width=150,height=210");
    }

    function 
    remLink() {
    if (
    window.sList && window.sList.open && !window.sList.closed)
    window.sList.opener null;
    }

    // -->
    </SCRIPT>
    <FORM NAME="stockForm">Enter your favorite tech stock:
    <INPUT TYPE="text" NAME="stockBox" SIZE="10" VALUE="">
    <INPUT TYPE="button" VALUE="list" onClick="showList(1)">
    </FORM> 

    <FORM NAME="form2">Enter your favorite tech stock:
    <INPUT TYPE="text" NAME="form2inputname" SIZE="10" VALUE="">
    <INPUT TYPE="button" VALUE="list" onClick="showList(2)">
    </FORM> 

    Child window
    PHP Code:
    <SCRIPT type="text/javascript">
    <!--

    function 
    pick(symbol) {
    if(
    window.opener)

    if(
    opener.num==1){
    window.opener.document.forms["stockForm"]["stockBox"].value symbol;
    }

    if(
    opener.num==2){
    window.opener.document.forms["form2"]["form2inputname"].value symbol;
    }
    window.close();
    }

    // -->
    </SCRIPT>


    <TABLE BORDER="1" CELLSPACING="0" CELLPADDING="5">
    <TR BGCOLOR="#cccccc"><TD><B>NYSE</B></TD><TD><B>NASDAQ</B></TD></TR>
    <TR><TD><A HREF="javascript:pick('AOL')">AOL</A></TD>
    <TD><A HREF="javascript:pick('CSCO')">CSCO</A></TD></TR>
    <TR><TD><A HREF="javascript:pick('CPQ')">CPQ</A></TD>
    <TD><A HREF="javascript:pick('INTC')">INTC</A></TD></TR>
    <TR><TD><A HREF="javascript:pick('NOK')">NOK</A></TD>
    <TD><A HREF="javascript:pick('SUNW')">SUNW</A></TD></TR>
    <TR><TD><A HREF="javascript:pick('LU')">LU</A></TD>
    <TD><A HREF="javascript:pick('AMZN')">AMZN</A></TD></TR>
    <TR><TD><A HREF="javascript:pick('T')">T</A></TD>
    <TD><A HREF="javascript:pick('MSFT')">MSFT</A></TD></TR>
    </TABLE> 
    Last edited by Mr J; 02-07-2007 at 08:40 PM.
    The silent one.

    The most dangerous thing in the world is an idea.
    The most dangerous person in the world is the one with an idea.

  • #3
    New Coder
    Join Date
    Dec 2006
    Posts
    41
    Thanks
    6
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Mr J View Post
    Here's one possiblity

    PHP Code:
    <SCRIPT type="text/javascript">
    <!--

    function 
    showList(n) {
    num=n
    sList 
    window.open("stocklist.html""list""width=150,height=210");
    }

    function 
    remLink() {
    if (
    window.sList && window.sList.open && !window.sList.closed)
    window.sList.opener null;
    }

    // -->
    </SCRIPT>
    <FORM NAME="stockForm">Enter your favorite tech stock:
    <INPUT TYPE="text" NAME="stockBox" SIZE="10" VALUE="">
    <INPUT TYPE="button" VALUE="list" onClick="showList(1)">
    </FORM> 

    <FORM NAME="form2">Enter your favorite tech stock:
    <INPUT TYPE="text" NAME="form2inputname" SIZE="10" VALUE="">
    <INPUT TYPE="button" VALUE="list" onClick="showList(2)">
    </FORM> 

    Child window
    PHP Code:
    <SCRIPT type="text/javascript">
    <!--

    function 
    pick(symbol) {
    if(
    window.opener)

    if(
    opener.num==1){
    window.opener.document.forms["stockForm"]["stockBox"].value symbol;
    }

    if(
    opener.num==2){
    window.opener.document.forms["form2"]["form2inputname"].value symbol;
    }
    window.close();
    }

    // -->
    </SCRIPT>


    <TABLE BORDER="1" CELLSPACING="0" CELLPADDING="5">
    <TR BGCOLOR="#cccccc"><TD><B>NYSE</B></TD><TD><B>NASDAQ</B></TD></TR>
    <TR><TD><A HREF="javascript:pick('AOL')">AOL</A></TD>
    <TD><A HREF="javascript:pick('CSCO')">CSCO</A></TD></TR>
    <TR><TD><A HREF="javascript:pick('CPQ')">CPQ</A></TD>
    <TD><A HREF="javascript:pick('INTC')">INTC</A></TD></TR>
    <TR><TD><A HREF="javascript:pick('NOK')">NOK</A></TD>
    <TD><A HREF="javascript:pick('SUNW')">SUNW</A></TD></TR>
    <TR><TD><A HREF="javascript:pick('LU')">LU</A></TD>
    <TD><A HREF="javascript:pick('AMZN')">AMZN</A></TD></TR>
    <TR><TD><A HREF="javascript:pick('T')">T</A></TD>
    <TD><A HREF="javascript:pick('MSFT')">MSFT</A></TD></TR>
    </TABLE> 
    hey mr J thanx for the help it is workin for two of the forms....awesome man..thank u very much.....appreciate it...i have one more question though....i got 2 forms workin.....what if i need 6 forms .......what shud i do to add 6 forms....thanx for the help....

  • #4
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    Add another if statement for each form to the script in the child window changing the form name and element name to suit the forms and in the onclick event for the forms button put the number relating to the form number

    You could also use the switch statement or go with the form and elements array
    The silent one.

    The most dangerous thing in the world is an idea.
    The most dangerous person in the world is the one with an idea.

  • #5
    New Coder
    Join Date
    Dec 2006
    Posts
    41
    Thanks
    6
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Mr J View Post
    Add another if statement for each form to the script in the child window changing the form name and element name to suit the forms and in the onclick event for the forms button put the number relating to the form number

    You could also use the switch statement or go with the form and elements array
    <SCRIPT type="text/javascript">
    <!--

    function pick(symbol)
    {
    if(window.opener)

    if(opener.num==1){
    window.opener.document.forms["stockForm"]["stockBox"].value = symbol;
    }
    if(opener.num==2){
    window.opener.document.forms["form2"]["form2inputname"].value = symbol;
    }
    if(opener.num==3){
    window.opener.document.forms["form3"]["form3inputname"].value = symbol;
    }
    if(opener.num==4){
    window.opener.document.forms["form4"]["form4inputname"].value = symbol;
    }
    if(opener.num==5){
    window.opener.document.forms["form5"]["form5inputname"].value = symbol;
    }
    if(opener.num==6){
    window.opener.document.forms["form6"]["form6inputname"].value = symbol;
    }
    window.close();
    }

    // -->
    </SCRIPT>
    hey mr J thanx for the help man....i pasted what i did.....but am unable to populate forms 3,4,5,6.........forms 1 and 2 r workin great.....and i also changed the onclick showlist(n) to the respective numbers like onclick showlist(3),onclick showlist(4), onclick showlist(5), onclick showlist(6)......but am unable to populate text boxes.....plz see the javascript code and lemme know what i shud do ...thank u very much for helpin

  • #6
    New Coder
    Join Date
    Dec 2006
    Posts
    41
    Thanks
    6
    Thanked 0 Times in 0 Posts
    hey Mr J got it working man.....thanx for the help.......


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •