35 users online (1 members and 34 guests)  


  Results 1 to 2 of 2

Related

  1. Moving elements    Forum: Javascript Forum
    Replies: 4
  2. help checking form elements in external js file    Forum: Javascript Forum
    Replies: 2
  3. Block elements within inline elements    Forum: CSS Forum
    Replies: 6
  4. Indenting Text in Form Elements    Forum: CSS Forum
    Replies: 4
  5. tekno elements    Forum: Show it off!
    Replies: 7
  1. #1
    deliriousthunder's Avatar
    Junior Member

    Status
    Offline
    Join Date
    Feb 2009
    Posts
    29

    Preselecting form elements

    Hi,

    Wasn't sure where to post, not sure which language (or combination of languages), this will require.

    I have 2 pages, one of the pages has a form.

    I'd like to click a link on one page, and when the page with the form loads, one of the options to be preselected according to a parameter from the original page.

    Even suggestions of what I should look into would be helpful.

    (Both pages are built using php)

    Thanks,
    Tom

  2. #2
    jthayne's Avatar

    Status
    Offline
    Join Date
    Aug 2008
    Location
    Texas
    Posts
    508

    Re: Preselecting form elements

    If you are familiar with passing variables via the URL, then this should be relatively simple for you.

    As an example, if you have the following link:
    Code:
    <a href="nextpage.php?one=choices">Next Page</a>
    use something similar to this PHP code on nextpage.php:
    PHP Code:
    $selection $_REQUEST['one'];

    echo 
    "<select>";
    echo 
    "<option value='one'".(($selection == 'one') ? " selected" "").">One</option>";
    echo 
    "<option value='two'".(($selection == 'two') ? " selected" "").">Two</option>";
    echo 
    "<option value='three'".(($selection == 'three') ? " selected" "").">Three</option>";
    echo 
    "</select>"
    Let me know if you have any questions.



Tags for this Thread