Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: 2 windows communicating

  1. #1
    Join Date
    Mar 2006
    Location
    Belgium
    Posts
    81
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Question 2 windows communicating

    For a sportsteam, i'm trying to make an "interactive" scoreboard for use with a beamer. It was pretty easy to write when i put it all in 1 window (the scoreboard and the controls). But now i need to split it up so the scoreboard itself is displayed fullscreen and passed thru the beamer and the controls are on another window and seen only on the laptop screen.
    what (javascript of html)-commands do i need to use to change the info on the scoreboard when a button is pressed on the control panel?

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    What's a beamer?
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Mar 2006
    Location
    Belgium
    Posts
    81
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    oops, sorry... i meant a projector
    here we usually call it a beamer...

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    I'm unfamiliar with that kind of setup but, if, on the lap top, the two windows are both going to be visible and the beamer is like an additional monitor showing only one of the two windows with the other window there but, off of its visible screen then here's what you do:

    Have your control page open the scores page:

    HTML Code:
    <input type="button" value="Open Scores Window" onclick="beamer=window.open('scores.htm');"><br>
    where scores.htm is the name of the page with the scores on it.

    Then, from the control page any variable on the scores page is now known as:

    Code:
    beamer.variableName
    So, let's say you have a variable on the scores page called team1, you can change its value using javascript by:

    Code:
    beamer.team1='Red Sox'
    from the control page.

    You can also change the value of a text input, the innerHTML of an element or even run a function that is on or available to the scores page from the control page simply by prefacing the normal code with beamer. examples:

    HTML Code:
    <input type="button" onclick="beamer.document.getElementById('team1').value='Red Sox'">
    on the control page will change the displayed value of:

    HTML Code:
    <input id="team1" type="text" value="Phillies">
    on the scores page and:

    HTML Code:
    <input type="button" onclick="beamer.alert('Red Sox')">
    on the control page will cause an alert on the scores page.

    etc.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Mar 2006
    Location
    Belgium
    Posts
    81
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    thanx a lot!

    i'm gonna give it a try. it'll take a while before it's finished, but when it's done, i'll post the result here.

  6. #6
    Join Date
    Mar 2006
    Location
    Belgium
    Posts
    81
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Not working

    Is anyone interested in taking a look at the script?

    (its pretty long, so I'll need to send it)

  7. #7
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Well, I tested out my advice before posting it. However, it is just a general outline of the principals involved. One thing I didn't mention is that say you are activating a function on the scores page from the control page and you need to pass it an element from the scores page as well, both must be prefaced with the scores page variable that was created when you opened it.

    Enough theory, you can archive your two pages as a .zip and attach them to a post here. Use the advanced editor and scroll down below it to the "Manage attachments" area. Once you've uploaded it, use the editors 'Attachments' drop down to insert it into the message.

    Or better yet, set up a demo of your two pages live on the web and include the URL to the control page in a message.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  8. #8
    Join Date
    Mar 2006
    Location
    Belgium
    Posts
    81
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Here is the code (in zip). Open the index file (is also the controlpanel, and there is a button to open the scoreboard itself. The scoreboard runs on fullscreen.
    Can someone look at it and help me out with the errors?

  9. #9
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    First problem is that you cannot setnames() onload of the control page because the scores page isn't open yet:

    Code:
    <BODY onLoad="setnames()" bgcolor="#ffffff" text="#000000">
    Get rid of the red part.

    Your setnames() function appears valid and will work after the scores page is loaded if setnames() is the only function on the control page. But, there must be a syntax error in one of the previous functions, this invalidates all code that follows. Here it is (at or around line#57 on the control page):

    Code:
    if scores.(board.A11points.value!=0){scores.board.A11points.value--;scores.board.AScore.value--;}}
    should be:

    Code:
    if (scores.board.A11points.value!=0){scores.board.A11points.value--;scores.board.AScore.value--;}}
    There could be other problems but, you seem to have grasped the fundamentals, and this should get you on your way. At least setnames() will now work.

    Since you will be testing and presumably using this locally as opposed to on the web, adding this line (in red):

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <!-- saved from url=(0014)about:internet -->
    to both pages, will prevent the local security warning.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  10. #10
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    What exactly is this "security warning" meant to do? Any writer of a malicious HTML page just has to add above line to disable it.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

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