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 2 of 2

Thread: Input & Popup.

  1. #1
    New to the CF scene
    Join Date
    Dec 2006
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Input & Popup.

    Hi again everyone.

    I try to restate the situation that I need with specific example below;

    1) Index.html

    Font1: [input name=font1 type=text] [a onclick="PopUP('Pop.html')]Link1[/a]

    Font2: [input name=font2 type=text] [a onclick="PopUP('Pop.html')]Link2[/a]

    Font3: [input name=font3 type=text] [a onclick="PopUP('Pop.html')]Link3[/a]


    2) Pop.html

    [a]Arial[/a]
    [a]Courier[/a]
    [a]Times[/a]
    [a]Tahoma[/a]

    - From 'Index.html', if I click 'Link 1', it will trigger 'Pop.html'. From 'Pop.html', if I click 'Arial', it will pass 'Arial' to 'font1' text input.
    - if I click 'Link 2', it will trigger "the same" 'Pop.html'. From 'Pop.html', if I click 'Times', it will pass 'Times' to 'font2' text input.

    The reason I need to do this is to avoid having to write '40' pop-up if I have '40' font input. Therefore, all the link will trigger "the same" pop-up. How do I do this with JS.

  • #2
    Regular Coder
    Join Date
    Oct 2003
    Location
    on a ship
    Posts
    574
    Thanks
    1
    Thanked 6 Times in 5 Posts
    source code for main window:
    Code:
    <html>
    <head>
    <script language="javascript">
    hiddenValue='';
    function PopUP(elem){
    hiddenValue=elem.previousSibling.id;
    var myWin=window.open('Pop.html');
    }
    
    function writeToInput(FonT){
    document.getElementById(hiddenValue).value=FonT;
    }
    
    </script>
    </head>
    <body>
    <a href="#" onClick="newwin()">new win</a>
    <input type=text name=font1 id=font1><a href="javascript:void(0);" onclick="PopUP(this);">link</a><br>
    <input type=text name=font2 id=font2><a href="javascript:void(0);" onclick="PopUP(this);">link</a><br>
    <input type=text name=font3 id=font3><a href="javascript:void(0);" onclick="PopUP(this);">link</a><br>
    <input type=text name=font4 id=font4><a href="javascript:void(0);" onclick="PopUP(this);">link</a><br>
    <input type=text name=font5 id=font5><a href="javascript:void(0);" onclick="PopUP(this);">link</a><br>
    <input type=text name=font6 id=font6><a href="javascript:void(0);" onclick="PopUP(this);">link</a><br>
    
    </body>
    </html>
    source code for Pop.html file:

    Code:
    <html>
    <head>
    <script type=text/javascript>
    function ToOpener(FonT){
    var op=opener.document?1:0;
    if(op){opener.writeToInput(FonT);}
    }
    </script>
    </head>
    <body>
    <a href="javascript:void(0);" onclick="ToOpener(this.innerHTML);">Arial</a><br>
    <a href="javascript:void(0);" onclick="ToOpener(this.innerHTML);">Courier</a><br>
    <a href="javascript:void(0);" onclick="ToOpener(this.innerHTML);">Times</a><br>
    <a href="javascript:void(0);" onclick="ToOpener(this.innerHTML);">Tohoma</a><br>
    </body>
    </html>
    I make no attempt at pretending like I'm a professional. I offer help with what knowledge I do have.


  •  

    Posting Permissions

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