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 4 of 4
  1. #1
    New Coder
    Join Date
    Apr 2005
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Update Textarea Value

    I have a window with frames. The bottom frame has a textarea and a button that opens a popup window. Within that popup window is a textarea that copies the text from the textarea on the main window. The popup window also has OK & CANCEL buttons. I want the OK button to check if the textarea has been changed, and if it has then I want the textarea of the main window to be updated.

    This is what I have:


    index.htm--------------------------\\
    <html><head></head>

    <frameset rows=42,58 noresize border="0">
    <frame src="info.htm" name="info" scrolling="no">
    <frame src="cxinfo.htm" name="data" marginheight="0px" marginwidth="10px" scrolling="no">
    </frameset>

    </html>
    ---------------------//


    cxinfo.htm---------------------------------------\\
    <html><head><script language="JavaScript">
    b = window.open("notesCX.htm","new","width=335,height=338,location=0,menubar=0,personal bar=0,status=0");
    b.focus();
    </script></head><body>

    <form name=cxNOTES>
    <textarea rows='6' cols='52' tabindex=10 id=NoteS style="font-size:12; font-family:arial"></textarea>
    <img src="notes.jpg" onClick="tikNotes()">
    </form>

    </body></html>
    -------------------------//


    notesCX.htm-----------------------------------------\\
    <html><head><Script Language=JavaScript>

    var pasteN = window.opener.document.myChoices.NoteS.value

    function buttonClick() {
    self.close();
    }

    function OKbutton() {

    }

    </script></head><body onLoad="document.viewNotes.theNotes.value=pasteN">

    <form name=cxList>
    <input type=button value="OK" style="width:65; height:22; font-size:12" onClick="OKbutton()">
    <input type=button value="Cancel" style="width:65; height:22; font-size:12" onClick="buttonClick()">
    </form>

    </body></html>
    --------------------//

  • #2
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,518
    Thanks
    3
    Thanked 506 Times in 493 Posts
    frameset
    PHP Code:
    <html>
    <
    head>
    <
    title>No title</title>
    <
    meta name="description" content="Makes a menu frame in the left. Hyperlinks in the menu frame are targeted to the main frame.">
    </
    head>
    <
    frameset rows="1*" cols="30%, *">
    <
    frame name="contents" src="LF.htm" scrolling="auto" marginwidth="10" marginheight="14" namo_target_frame="detail">
    <
    frame name="detail" id="detail" src="RF.htm"  scrolling="no" marginwidth="10" marginheight="14">
    <
    noframes>
    <
    body bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">

    <
    p>You need a browser that supports frame to veiw this page.</p>
    </
    body>
    </
    noframes>
    </
    frameset>
    </
    html
    LH frame - LH.htm
    PHP Code:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
        "http://www.w3.org/TR/html4/strict.dtd"
    >

    <
    html>

    <
    head>
      <
    title></title>
    <
    SCRIPT LANGUAGE="javascript">

    function 
    LinkUp(){
     if (
    document.getElementById('DDlinks').selectedIndex<1){ return; }
     
    Link=document.getElementById('DDlinks').options[document.getElementById('DDlinks').selectedIndex].value.split('?');
     if (
    Link.length==1){
      
    window.top.location=Link[0];
     }
     if (
    Link.length==2){
      eval(
    'top.'+Link[0]+'.location=Link[1];');
     }
    }
    </SCRIPT>
    </head>

    <body>
    Detail
    <FORM NAME="DropDown">
    <SELECT NAME="DDlinks" id="DDlinks" onchange="javascript:number=this.selectedIndex;" >
    <OPTION SELECTED>--> Choose a Link <--
    <OPTION VALUE="detail?http://www.js-examples.com">Page One
    <OPTION VALUE="http://www.vicsjavascripts.org.uk">Page Two
    <OPTION VALUE="contents?http://www.sitepoint.com">Page Three
    </SELECT>

    <INPUT TYPE="BUTTON" VALUE="Click to Go!" onClick="LinkUp()">
    </FORM>

    <script language="JavaScript" type="text/javascript">
    <!--
    // Script produced with PopUpGenerator
    // by Vic Phillips http://www.vicsjavascripts.org.uk

    // Insert this script between the <header> tags

    var pugWindow=null;

    function pugWindow0Do(){
     pugCloseWin();
     pugWindow=window.open(' ','pugWindow0','width=200px,height=200px,resizable=yes');
     pugWindow.document.write(
     '<head><TITLE>trial</TITLE></head> ',
     '<body style="font-family:times, "Times New Roman", serif;"  > ',
     '<center> ',
     '<textarea id="TextArea2" rows="10" cols="20">Text Area 2</textarea><input type="button" name="" value="Change" onclick="opener.OK();"><br>',
     '',
     '</center></body></html> ',
     '');
    }

    function pugCloseWin(){
    // Recommended - include onunload="pugCloseWin();" in the <body> tag.
     if (pugWindow && !pugWindow.closed){ pugWindow.close(); }
    }


    //-->
    </script>

    <script language="JavaScript" type="text/javascript">
    <!--
    var TxtAreaLast='Text Area 1';

    function OK(){
     if (top.detail.document.getElementById('TextArea1').value!=TxtAreaLast){
      ask=confirm('Change Area2');
      if (ask){
       window.pugWindow.document.getElementById('TextArea2').value=top.detail.document.getElementById('TextArea1').value;
      }
     }
     TxtAreaLast=top.detail.document.getElementById('TextArea1').value;
    }
    //-->
    </script>

    Place the follow calls within the tags
    of the element to click to display the popup


    The call for AnyHTML PopUp title :- trial
    <br>
    <br>
    <br>

    <span onclick="javascript:pugWindow0Do();" >Click here to Open PopUp</span>

    <br>
    </body>

    </html> 
    RH Frame - RH.htm
    PHP Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
        "http://www.w3.org/TR/html4/strict.dtd"
    >

    <
    html>

    <
    head>
      <
    title></title>
    </
    head>

    <
    body>
    Content
    <textarea id="TextArea1" rows="10" cols="20">Text Area 1</textarea>
    <
    br>
    </
    body>

    </
    html

    There is come other code in the LH Frame I havent cleaned out

  • #3
    New Coder
    Join Date
    Apr 2005
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Wa?

    I'm not trying to be rude, but REALY!?

    None of this answers my request. All I see is code to setup a frameset mixed with some of my code, which BTW I have to apologize for as it contains inconsistent variable names.

    Corrected code:


    cxinfo.htm---------------------------------------\\
    <html><head><script language="JavaScript">
    function tikNotes() {
    b = window.open("notesCX.htm","new","width=335,height=338,location=0,menubar=0,personal bar=0,status=0");
    b.focus();
    }
    </script></head><body>

    <form name=myChoices>
    <textarea rows='6' cols='52' tabindex=10 id=NoteS style="font-size:12; font-family:arial"></textarea>
    <img src="notes.jpg" onClick="tikNotes()">
    </form>

    </body></html>
    -------------------------//


    notesCX.htm-----------------------------------------\\
    <html><head><Script Language=JavaScript>

    var pasteN = window.opener.document.myChoices.NoteS.value

    function buttonClick() {
    self.close();
    }

    function OKbutton() {

    }

    </script></head><body onLoad="document.viewNotes.theNotes.value=pasteN">

    <form name=viewNotes>
    <textarea cols=34 rows=24 id=theNotes></textarea><br>
    <input type=button value="OK" style="width:65; height:22; font-size:12" onClick="OKbutton()">
    <input type=button value="Cancel" style="width:65; height:22; font-size:12" onClick="buttonClick()">
    </form>

    </body></html>
    --------------------//

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    notesCX.htm:
    Code:
    <html>
    <head>
    <title>Edit Notes</title>
    <script type="text/javascript">
    
    function closeWin() {
      if (opener && !opener.closed) opener.focus(); //set focus to opener if it's still open
      self.close(); 
    }
    
    function setNote(fromOpenerToSelf) {
      if (opener && !opener.closed){ //make sure opener is open
        if (fromOpenerToSelf){ //set notes in this page
          document.viewNotes.theNotes.value = opener.document.myChoices.NoteS.value;
        }
        else{ //update notes in opener
          opener.document.myChoices.NoteS.value = document.viewNotes.theNotes.value;
        } 
      }
      closeWin();
    }
    </script>
    </head>
    <body onload="setNote(true)">
    <form name="viewNotes">
    <textarea cols="34" rows="24" id="theNotes" name="theNotes"></textarea><br />
    <input type="button" value="OK" style="width:65; height:22; font-size:12" onclick="setNote(false)" />
    <input type="button" value="Cancel" style="width:65; height:22; font-size:12" onclick="closeWin()" />
    </form>
    </body>
    </html>
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________


  •  

    Posting Permissions

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