/    Sign up×
Community /Pin to ProfileBookmark

Two questions about HTML

  • 1. I am creating a form with an age section. I am intent on using a drop down box. Its gonna take me ages to sit and type from 1900 – 2005
  • <SELECT ….><OPTION>1900<OPTION>1901 —- <OPTION>2005</SELECT>

    Is there a method where by i can do an all command where it create a drop down list bewteen two dates?

  • 2. I have more than one screen of data using <INPUT TYPE=”text” or “radio”> etc forms that will be sent to my email via a submit button. Is there a method where by all the screens are able to come to my email in one message?
  • (like an ADD button that adds all details until SUBMIT button used?)

    to post a comment
    HTML

    9 Comments(s)

    Copy linkTweet thisAlerts:
    @proutonJul 22.2005 — #1 -- If you think it's a pain to type all of those, think about the pain it will be to use such a dropdown list. That's a lot of scrolling for something the user would probably rather just type in.

    #2 -- You have to remember that once the page has been sent from the server, there no longer exists a connection between the server and the browser. When the user hits the "send" button of a form, a whole new connection is started, and ends when the next page is received. So to carry information across pages, you have to bury that information in the second and subsequent pages (hidden form fields). But it also means that you have to be running a server side language like PHP, ASP or Perl to accept the first form's fields and dynamically create the second page to include the values from the first page, and so on. Plain html forms can send the values to an email address or Perl script, but nothing more than that.
    Copy linkTweet thisAlerts:
    @NogDogJul 22.2005 — You could populate that huge list of dates using a fairly simple script (such as in PHP, Perl, or ASP), though as Prouton points out, it might be easier to just make it a text input field (then validate on the server side processing that the value is numeric and within the desired range). But if you really want a selection list with 105 options, you could do it in PHP for example as:
    [code=php]
    <select name='year_birth'>
    <?php
    $thisYear = date('Y');
    for($year = $thisYear - 105; $year <= $thisYear; $year++)
    {
    echo "<option value='$year'>$year</option>n";
    }
    ?>
    </select>
    [/code]
    Copy linkTweet thisAlerts:
    @peteybauthorJul 22.2005 — this code doesnt work, it simply brings a dropdown list with not dates.

    have i missed something?
    Copy linkTweet thisAlerts:
    @NogDogJul 22.2005 — 
  • 1. Do you have PHP installed/available on your web server?


  • 2. If yes for #1, did you name your file with a .php suffix?
  • Copy linkTweet thisAlerts:
    @peteybauthorJul 22.2005 — have php available, uploaded the files and changed it from .html to .php but it still doesnt bring up a date.

    any ideas?
    Copy linkTweet thisAlerts:
    @NogDogJul 22.2005 — have php available, uploaded the files and changed it from .html to .php but it still doesnt bring up a date.

    any ideas?[/QUOTE]

    It worked fine on my 'puter. If you do a "view source" on the page, what do you see (if anything) between the <select>...</select> tags?
    Copy linkTweet thisAlerts:
    @proutonJul 22.2005 — Yeah, I tried his code as well and it worked fine, so you might want to post a test page URL we can look at.
    Copy linkTweet thisAlerts:
    @rpassmorJul 22.2005 — I think it virtually the same thing, but mine works for me (using NogDog's $thisYear variable)

    [code=php]
    <?php
    $thisYear = date('Y');
    echo '<select>';
    for ($i = 1900; $i <= $thisyear; $i++)
    {
    echo '<option>' . $i . '</option>';
    }
    echo '</select>';
    ?>[/code]
    Copy linkTweet thisAlerts:
    @proutonJul 23.2005 — NogDog's method for the setting the initial year provides a sliding window of dates. If the assumption is that the oldest age is going to be 105, then there's no reason to fix the first date (and the top of the list) at 1900 for the next five or ten years.

    Second, in re-writing the "option" statement, you missed the value parameter, so the form isn't going to return a value.
    ×

    Success!

    Help @peteyb spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 6.2,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @meenaratha,
    tipped: article
    amount: 1000 SATS,

    tipper: @meenaratha,
    tipped: article
    amount: 1000 SATS,

    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,
    )...