Pre load a HTML site with variables

for everything else
Post Reply
seulater
Posts: 445
Joined: Fri Apr 25, 2008 5:26 am

Pre load a HTML site with variables

Post by seulater »

I want to create a web page with say 5 radio buttons labeled #1-5, and a submit button.
since I am no HTML expert I am looking to see if this can be done.

Lets say the user goes to the NB web page and clicks the #3 radio button then presses submit. closes the browser, then re-opens it and goes to the web page again. I need to somehow tell the web page this time that the #3 radio button should be clicked.

Can one pre load variables into a HTML web page ?

Another example would be if I had a drop down list with 20 elements in it. and the user clicked the 15 element, when the web page is accessed again, I would like that 15'th element to be at the top rather that the default 1'st.

Hope I made sense of all this.
thomastaranowski
Posts: 82
Joined: Sun May 11, 2008 2:17 pm
Location: Los Angeles, CA
Contact:

Re: Pre load a HTML site with variables

Post by thomastaranowski »

Lets say the user goes to the NB web page and clicks the #3 radio button then presses submit. closes the browser, then re-opens it and goes to the web page again. I need to somehow tell the web page this time that the #3 radio button should be clicked.

Can one pre load variables into a HTML web page ?

Check out the <!--FUNCTIONCALL xxx --> feature of the web server. This is what you would use to dynamically generate your web page with the desired HTML.

A simple example:

Code: Select all

<INPUT TYPE="radio" VALUE="1" NAME="button1" <!--FUNCTIONCALL isButton1Checked -->> Radio1
<INPUT TYPE="radio" VALUE="2" NAME="button2" <!--FUNCTIONCALL isButton2Checked -->> Radio2
Then, in your code define the following function:

Code: Select all

extern "C" void isButton1Checked(int sock, PCSTR url) {
        if(button1Checked)
  	  writestring(sock, "checked");
}
To make this work, when the user 'submit's, you will need to store that the state of the button that was checked at the time of submission. An easy way is to store it off in some static or global variable.
Another example would be if I had a drop down list with 20 elements in it. and the user clicked the 15 element, when the web page is accessed again, I would like that 15'th element to be at the top rather that the default 1'st.
Once again, generate the HTML on the fly, and write it out dynamically via you're function call, based on the current stored state of the system
seulater
Posts: 445
Joined: Fri Apr 25, 2008 5:26 am

Re: Pre load a HTML site with variables

Post by seulater »

Thanks much, will give it a try.

I tried it using DreamWeaver, and all it wants to do is complain about it. am i not adding somthing else ?

when i add a button it adds this to the code section
<input name="button1" type="radio" value="1" />
thomastaranowski
Posts: 82
Joined: Sun May 11, 2008 2:17 pm
Location: Los Angeles, CA
Contact:

Re: Pre load a HTML site with variables

Post by thomastaranowski »

You're close with that dreamweaver code snippet. The thing to keep in mind is that the FUNCTIONCALL syntax is not standard HTML at all, so dreamweaver will complain loudly.

The line in question:
<input name="button1" type="radio" value="1" />

You probably want to make that line look like this:
<input name="button1" type="radio" value="<!--FUNCTIONCALL getButton1State -->"/>

Thomas Taranowski
Netburner Consultant
baringforge.com
seulater
Posts: 445
Joined: Fri Apr 25, 2008 5:26 am

Re: Pre load a HTML site with variables

Post by seulater »

i have tried that and just about every other way i could think of. even if i allow it to complain and try it, i still am not able to make the radio button checked or not.
i know its talking to the NB board, as there are times when it will say "checked" on the web page, depending on where i place the "<!--FUNCTIONCALL getButton1State -->"
Post Reply