Results 1 to 4 of 4

Thread: javascript/PHP/DOM question

  1. #1
    Join Date
    Apr 2005
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default javascript/PHP/DOM question

    I have an odd question that I havent found an answer to in the specs.

    If an HTML page (generated by PHP) is changed on client side bu Javascript/DHTML means, (e.g. additional form fields/values added),
    do the new DOM entities continue to exist when the form is submitted
    (to PHP_SELF) ?

    (I want to use Javascript to let user manipulate list contents on client side
    then submit changes for DB update and, being a Javascript/DOM dummy,
    not sure how to access the new values)

    Thanks in advance,
    Wyzyrd
    <}

  2. #2
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by wyzyrd
    If an HTML page (generated by PHP) is changed on client side bu Javascript/DHTML means, (e.g. additional form fields/values added), do the new DOM entities continue to exist when the form is submitted (to PHP_SELF) ?
    The name/value pairs of the new form controls should be submitted, yes. However, I have read that sometimes this doesn't happen (with IE, I think), but I can't recall experiencing it personally.

    (I want to use Javascript to let user manipulate list contents on client side then submit changes for DB update and
    That's fine, but assuming this is for a public environment, you should also be providing a server-side fallback that will perform the manipulation if the client isn't capable of doing so.

    being a Javascript/DOM dummy, not sure how to access the new values)
    You have to remember that the values of option elements are only submitted if they have been selected. Merely existing is not enough.

    Though in principle you can use a client-side script to select all of the values prior to submission, the server-side fallback would also need to know what is contained in the select element. What you could do is keep a list of items as session data on the server. If the user uses the fallback to add or remove from the select element, this list can be updated and used during final submission. Any data from the actual element can be ignored.

    I'd post some code, but I have no real means of testing at this precise moment in time.

    Mike

  3. #3
    Join Date
    Apr 2005
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up

    Thanks, the info is very helpful

    Quote Originally Posted by mwinter
    That's fine, but assuming this is for a public environment, you should also be providing a server-side fallback that will perform the manipulation if the client isn't capable of doing so.
    This won't be for a publicly-viewable service - a LAN/VPN where our customer
    (who cares more about style than substance) is in control of browser/version
    (otherwise I'd do it ALL server-side)

    Quote Originally Posted by mwinter
    You have to remember that the values of option elements are only submitted if they have been selected. Merely existing is not enough.
    Current design/plan is to use nested <ul> items (names of groups/members of each group) and a table (possible members of the groups and associated data) for a "combo-box" effect .(similar to a contact list with sorting by interest subgroups) The <li> and table row entries will contain <input type=hidden> data items as well as a hidden item-count. Javascript/DHTML on client side will let them "mix and match" subgroup member lists. The PHP code on server side will
    insert/delete/modify/fetch DB entries to be displayed.

    Seems like it should work, but I wasnt able to find info on whether or not
    internal page changes (esp new items) persisted when page was reprocessed server side.

    Thanks again
    Wyzyrd
    <

  4. #4
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by wyzyrd
    Seems like it should work, but I wasnt able to find info on whether or not internal page changes (esp new items) persisted when page was reprocessed server side.
    Just to be explicit, dynamic modifications client-side will not be transferred server-side, nor will they be stored in the cache. Refreshing also destroys any changes. However, dynamic modifications - such as new form controls - should (bar any bugs) affect client-to-server communications.

    Mike

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
  •