It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming HTML Forum

help with form input

help with form input

Postby gncreditcards on Mon Jan 21, 2008 4:39 am

I have this form and what I want is that every time you press the button Vote in the text that appears join a number more, if it appears Example one to push the button will appear if a 2 appears repeat 3

<form name="Vote">
<input type="text" value="" name="sky">
<input type="hidden" value="1" name="blue">
<input type="button" value="Vote" onClick="document.Vote.sky.value =(document.Vote.blue.value)">
</form>
gncreditcards
 
Posts: 3
Joined: Mon Jan 21, 2008 4:23 am

Postby leonard on Mon Jan 21, 2008 8:20 am

just displaying a number is easy, just add this to your onclick:
Code: Select all
document.Vote.blue.value = Number(document.Vote.blue.value)+1;

The more intersting question would probably be where you want to store the data. In the example above it is only stored in a simple formfield of the client.

cheers!
- leonard
:%s/^M//
There are 10 kinds of people:
Those who understand binary and those who don't.
User avatar
leonard
100+ Club
 
Posts: 147
Joined: Tue Dec 18, 2007 7:11 am
Location: Switzerland

Postby gncreditcards on Tue Jan 29, 2008 3:49 am

Is excelente. Thank you for this help, but Al put the script on my website where visitors click on Voting increases the number in the vote of the page and update the site when the increase in the voting to begin again in 1.

I want continous increase, but when the people refresh the page the counter begining in 1
Last edited by gncreditcards on Tue Jan 29, 2008 11:28 pm, edited 1 time in total.
gncreditcards
 
Posts: 3
Joined: Mon Jan 21, 2008 4:23 am

Postby leonard on Tue Jan 29, 2008 7:59 am

gncreditcards wrote:but Al put the script on my website where visitors click on Voting increases the number in the vote of the page and update the site when the increase in the voting to begin again in 1.
Whatever you exactly mean with that sentence... but yes, it begins with 1 again.

As I have stated before
leonard wrote:The more intersting question would probably be where you want to store the data. In the example above it is only stored in a simple formfield of the client.

We are now at the question: What can HTML do and what not?

In the example we have a static HTML-code. When you put it on a website, the webserver will always return the same code, meaning that the vote-field will always start with '1' for every user who visits the page.
At the moment, the webserver does not know that the button is being pressed, because when it is pressed, the only thing that happens is the number increments within the useragent (Internet Explorer/Firefox of the user).

What you want is that every user visiting the page can see how many times the button 'Vote' has been pressed by others, right?
This means that the information of a user pressing the button must be stored somewhere.

Where do you think the information should be stored?
Answer the question and I will continue to help.


cheers!
- leonard
:%s/^M//
There are 10 kinds of people:
Those who understand binary and those who don't.
User avatar
leonard
100+ Club
 
Posts: 147
Joined: Tue Dec 18, 2007 7:11 am
Location: Switzerland

Postby gncreditcards on Tue Jan 29, 2008 11:36 pm

Yes I want that every user visiting the page can see how many times the button 'Vote' has been pressed by others, right
How stored my informations in HTML
gncreditcards
 
Posts: 3
Joined: Mon Jan 21, 2008 4:23 am

Postby leonard on Wed Jan 30, 2008 7:19 am

gncreditcards wrote:stored my informations in HTML
Wrong.
HTML cannot store the information.

The information needs to be stored on the server by a serverside-function. What HTML can do is submit the information to the server, but the storing needs to be done by the server itself. Only the server can know how many users have pressed the button.

What we need to do are three steps:
1) create a HTML-submit-form
2) create a serverside-function which stores the data.
3) create a serverside function to dynamically modify the HTML-page so that the correct number of votes are displayed.

Now my question to you:
what serverside language does your webserver support?
- CGI?
- PHP?
- Java (Servlets)?

If you don't know it, you should ask your webhoster.
If your webserver does not support any serverside language, your vote-page won't work.

cheers!
- leonard
:%s/^M//
There are 10 kinds of people:
Those who understand binary and those who don't.
User avatar
leonard
100+ Club
 
Posts: 147
Joined: Tue Dec 18, 2007 7:11 am
Location: Switzerland


Who is online

Users browsing this forum: No registered users and 4 guests