Generating Dynamic HTML pages

Discussion in 'Javascript' started by Vanitha, Mar 21, 2005.

  1. Vanitha

    Vanitha Guest

    Hi All,

    I am developing a Web based application for an embedded target, using
    BOA webserver.

    I need to return some values to the HTML client. I am using CGI-C to
    extract the values sent by the client from the server.

    I dont want to generate the entire HTML page each time from the
    server.'cos i need to refresh the status less than a second..

    Is there a way for me to pass the Name,Value pairs alone to the HTML
    client and using javascript i can assign the value to the HTML client
    form.

    I appreciate any inputs on this

    Thanks
    Vanitha, Mar 21, 2005
    #1
    1. Advertising

  2. Vanitha

    Erwin Moller Guest

    Vanitha wrote:

    > Hi All,
    >
    > I am developing a Web based application for an embedded target, using
    > BOA webserver.
    >
    > I need to return some values to the HTML client. I am using CGI-C to
    > extract the values sent by the client from the server.
    >
    > I dont want to generate the entire HTML page each time from the
    > server.'cos i need to refresh the status less than a second..
    >
    > Is there a way for me to pass the Name,Value pairs alone to the HTML
    > client and using javascript i can assign the value to the HTML client
    > form.
    >
    > I appreciate any inputs on this
    >
    > Thanks


    Hi,

    You could use a hidden frame for this.
    It refreshes every 1 sec after loading (maybe using an onLoad function and a
    window.setTimeout() ).

    Make the page in the hidden frame small, so it IS generated dynamically (how
    else), but it is just small.
    You will need some serverside scripting to accomplish this.

    Another approach would be to let the server write a new file that you
    reload. COuld be plain HTML-file, but still the server is responsible to
    write this file every time some data gets updated.

    The file could contain something like this:

    suppose this script is called: example1.html

    <html>
    <head>

    <script type="text/javascript">
    // this value is written dynamically
    var newvalue=42;

    // call some function in the frameset definition
    parent.newValueSet(newvalue);

    // reload this page in 1 second
    setTimeout("location='example.html';" , 1000);
    </script>

    </head>
    <body>
    empty :)
    </body>
    </html>

    Regards,
    Erwin Moller
    Erwin Moller, Mar 21, 2005
    #2
    1. Advertising

  3. Vanitha

    Remi Bastide Guest

    (Vanitha) wrote:

    >Hi All,
    >
    >I am developing a Web based application for an embedded target, using
    >BOA webserver.
    >
    >I need to return some values to the HTML client. I am using CGI-C to
    >extract the values sent by the client from the server.
    >
    >I dont want to generate the entire HTML page each time from the
    >server.'cos i need to refresh the status less than a second..
    >
    >Is there a way for me to pass the Name,Value pairs alone to the HTML
    >client and using javascript i can assign the value to the HTML client
    >form.
    >
    >I appreciate any inputs on this
    >

    You could consider using the XML HTTP request object, see:
    http://jibbering.com/2002/4/httprequest.html
    Remi Bastide, Mar 21, 2005
    #3
  4. Vanitha

    Guest

    Erwin Moller wrote:
    > Vanitha wrote:
    >
    > > Hi All,
    > >
    > > I am developing a Web based application for an embedded target,

    using
    > > BOA webserver.
    > >
    > > I need to return some values to the HTML client. I am using CGI-C

    to
    > > extract the values sent by the client from the server.
    > >
    > > I dont want to generate the entire HTML page each time from the
    > > server.'cos i need to refresh the status less than a second..
    > >
    > > Is there a way for me to pass the Name,Value pairs alone to the

    HTML
    > > client and using javascript i can assign the value to the HTML

    client
    > > form.
    > >
    > > I appreciate any inputs on this
    > >
    > > Thanks

    >
    > Hi,
    >
    > You could use a hidden frame for this.
    > It refreshes every 1 sec after loading (maybe using an onLoad

    function and a
    > window.setTimeout() ).
    >
    > Make the page in the hidden frame small, so it IS generated

    dynamically (how
    > else), but it is just small.
    > You will need some serverside scripting to accomplish this.
    >
    > Another approach would be to let the server write a new file that you


    > reload. COuld be plain HTML-file, but still the server is responsible

    to
    > write this file every time some data gets updated.
    >
    > The file could contain something like this:
    >
    > suppose this script is called: example1.html
    >
    > <html>
    > <head>
    >
    > <script type="text/javascript">
    > // this value is written dynamically
    > var newvalue=42;
    >
    > // call some function in the frameset definition
    > parent.newValueSet(newvalue);
    >
    > // reload this page in 1 second
    > setTimeout("location='example.html';" , 1000);
    > </script>
    >
    > </head>
    > <body>
    > empty :)
    > </body>
    > </html>
    >
    > Regards,
    > Erwin Moller
    , Mar 21, 2005
    #4
  5. Vanitha

    Guest

    Hi Erwin,

    I actually dont want to use the second approach, since the HTML files
    are developed by someone
    else and i actually need to copy+paste the code to use printf's in my
    "C" code to output
    html. This is very tedious and i am not getting the images that are
    used in the HTML files


    Hence i want to use the second approach that you have mentioned, the
    hidden frame approach
    I actually have created a hidden frame using this code

    <FRAMESET COLS="200%,*" framespacing="0">
    <FRAME SRC="status.htm" NAME="mstatus" SCROLLING=AUTO>
    <FRAME SRC="hidden.htm" NAME="hidden" SCROLLING=AUTO>
    </FRAMESET>

    And when the user clicks some button in status.htm,i am executing this
    cgi


    window.parent.hidden.location="http://10.0.0.10/cgi-bin/getstat.cgi


    The cgi script is getting executed in the server side, but i dont know
    how to send
    the response from the server to the client and then how to update that
    in the
    status.htm file.

    can you please let me know how to do the server side scripting. I am
    bit
    new to javascript, i am basically a "C" programmer.
    , Mar 21, 2005
    #5
  6. Vanitha

    Guest

    Hi Erwin,

    I actually dont want to use the second approach, since the HTML files
    are developed by someone
    else and i actually need to copy+paste the code to use printf's in my
    "C" code to output
    html. This is very tedious and i am not getting the images that are
    used in the HTML files


    Hence i want to use the second approach that you have mentioned, the
    hidden frame approach
    I actually have created a hidden frame using this code

    <FRAMESET COLS="200%,*" framespacing="0">
    <FRAME SRC="status.htm" NAME="mstatus" SCROLLING=AUTO>
    <FRAME SRC="hidden.htm" NAME="hidden" SCROLLING=AUTO>
    </FRAMESET>

    And when the user clicks some button in status.htm,i am executing this
    cgi


    window.parent.hidden.location="http://10.0.0.10/cgi-bin/getstat.cgi


    The cgi script is getting executed in the server side, but i dont know
    how to send
    the response from the server to the client and then how to update that
    in the
    status.htm file.

    can you please let me know how to do the server side scripting. I am
    bit
    new to javascript, i am basically a "C" programmer.
    , Mar 21, 2005
    #6
  7. Vanitha

    Erwin Moller Guest

    wrote:

    > Hi Erwin,
    >
    > I actually dont want to use the second approach, since the HTML files
    > are developed by someone
    > else and i actually need to copy+paste the code to use printf's in my
    > "C" code to output
    > html. This is very tedious and i am not getting the images that are
    > used in the HTML files
    >
    >
    > Hence i want to use the second approach that you have mentioned, the
    > hidden frame approach
    > I actually have created a hidden frame using this code
    >
    > <FRAMESET COLS="200%,*" framespacing="0">


    That is strange, you ment probably something like:
    <FRAMESET COLS="*,0" framespacing="0">

    So the hidden frame is invisible (0 pixels)

    But this is not important for the functionality. :)

    > <FRAME SRC="status.htm" NAME="mstatus" SCROLLING=AUTO>
    > <FRAME SRC="hidden.htm" NAME="hidden" SCROLLING=AUTO>
    > </FRAMESET>
    >
    > And when the user clicks some button in status.htm,i am executing this
    > cgi
    >
    >
    > window.parent.hidden.location="http://10.0.0.10/cgi-bin/getstat.cgi
    >
    >
    > The cgi script is getting executed in the server side, but i dont know
    > how to send
    > the response from the server to the client and then how to update that
    > in the
    > status.htm file.
    >
    > can you please let me know how to do the server side scripting. I am
    > bit
    > new to javascript, i am basically a "C" programmer.


    Well, what can I do for you?
    I can help you a little with the setup, but I cannot give you excact code
    because I don't know anything about the project.

    I suggest you do the following:
    1) Make sure you get some basic Javascript knowledge in.
    Pay extra attention to:
    a) Communication between different windows.
    (Every html in a frame is considered a window.)
    eg: parent.frames.hidden etc like you used already
    Make sure you can pass basic values from 1 window to the next without any
    serverside calls.
    eg: To call a function in your frameset, use:
    window.parent.someFunction();

    Of course you need to define a function in your parentframe called that
    name:

    So to experiment start with this in your parentframe:
    <FRAMESET COLS="*,0" framespacing="0">
    <FRAME SRC="status.htm" NAME="mstatus" SCROLLING=AUTO>
    <FRAME SRC="hidden.htm" NAME="hidden" SCROLLING=AUTO>
    </FRAMESET>

    <script type="text/javascript>
    function someFunction(aNumber){
    alert ("I received: "+aNumber);
    }
    </script>


    b) Make sure you have a look at the function setTimeout()
    You need this to keep polling your server for fresh results.

    c) How to manipulate content on a webpage with javascript.

    You were talking about forms, so here is an example:

    html on a page:
    <form action="bla.cgi" name="myForm">
    <input type="text" name="age">
    <input type="submit">
    </form>

    Now you can alter the content of the textelement that is named age as
    follows:
    document.forms["myForm"]["age"].value = 55;

    If you want to manipulate existing text on the page instead of forms, ask
    somebody else, because I never do that. :p


    and 2)
    Make sure you rewrite the page that is polled every second by the clients by
    first making a simple page.
    You can use the one I posted before as a basic template.
    You ONLY have to make sure that the process serverside that updates the
    information is parsing the right value on the place where I putted the 42.

    And a last tip:
    http://www.w3schools.com/ is a great place to check up some basic
    webconcepts for starters.
    http://www.w3schools.com/js/default.asp for example is a crashcourse on
    Javascript, but you will find a lot more.

    Since you are a C programmer, I think you should be able to master a lot
    over there without too much pain. ;-)

    Good luck,

    Regards,
    Erwin Moller
    Erwin Moller, Mar 21, 2005
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lim siew Cheng

    Dynamic generating ascx within <html>?

    Lim siew Cheng, Aug 28, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    379
    Lim siew Cheng
    Aug 28, 2003
  2. Replies:
    1
    Views:
    655
    Kevin Spencer
    Oct 31, 2006
  3. jonjon
    Replies:
    0
    Views:
    197
    jonjon
    Oct 29, 2003
  4. Replies:
    3
    Views:
    118
    Martin Honnen
    Sep 14, 2005
  5. Faisal Vali
    Replies:
    10
    Views:
    220
    Thomas 'PointedEars' Lahn
    Jun 21, 2008
Loading...

Share This Page