SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    May 2005
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Pre-check checkbox onload based on previous message

    Hi,

    I am creating a form in which a checkbox is checked based on the info from previous page.

    The info I am passing is the client ID (which is a number I can pass in the URL variable)

    In the form I have a list of clients (with checkboxes next to them)

    Now if you come from a specific client page the checkbox with the client name should be already checked since you are getting info regarding that client, with the option of selecting other clients..

    So any idea on how I can accomplish this using Javascript?

    Regards

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    Javascript is not the right tool for this job.
    You should submit the first form to a server-side script, such as PHP, so that the server-side script can then build the next page with information from the previous page.

    If however you insist on using JavaScript, your form is highly likely to fail. JavaScript is completely optional, and you need to understand that it should not be used for any fundamental behaviours.
    Having said that, here is code to access the querystring via JavaScript.

    JavaScript can only access forms that are submitted via "get". Forms that are submitted via "post" are not in any way accessible via JavaScript. You come back to requiring server-side code for such requirements.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •