Results 1 to 11 of 11

Thread: removing html checkboxes

  1. #1
    Join Date
    Mar 2010

    removing html checkboxes

    I have a checkbox list and I need to be able to dynamically remove a box from the list. More importantly, I need to have it permanently removed from the html file, so that the next time any user opens the page, a checkbox that has been previously removed will not show up.

    I can write a script to remove it from the page, but the next time I load the page, the original list will still be there.

    An example of what I need to do is below

    I have this page:

    [x] A
    [ ] B
    [x] C

    {delete checked}

    when the delete checked button is clicked, the A and C checkbox will be removed, and I'll be left with the following:

    [ ]B

    {delete checked}

    However, the next time the page is loaded, I need the 2nd page to show up, not the first.


  2. #2
    Join Date
    Jun 2009
    Using Javascript, you hide the checkboxes, right?

    Within a <form> element, create <input> elements of type "hidden" and set 'name' and 'value' attributes. Your Javascript will set the value of the hidden inputs when the checkbox is set or unset (you might use the values of the checkbox "true" or "false").

    When user requests the next page (re-load?), you must make sure the request is in a form submission: action="yourURL.php" method="get"

    On the server side, you use PHP for retrieving $_GET['name'] form values, which indicate which checkboxes were "deleted".

    Your 'yourURL.php' document should look something like this:

    <!DOCTYPE....use Strict HTML
    PHP Code:
    if ($_GET['chboxA'] != 'unset')
    "<input type=\"checkbox\" name=...> A";
       if (
    $_GET['chboxB'] != 'unset')
    "<input type=\"checkbox\" name=...> B";
       if (
    $_GET['chboxC'] != 'unset')
    "<input type=\"checkbox\" name=...> C";

    This should guarantee that the choices are not included in the HTML of the served document.
    Last edited by mavigozler; 03-19-2010 at 10:43 AM.

  3. #3
    Join Date
    Mar 2010
    Mavigozler, thanks for responding

    The problem with this is that I already have a submit button set to run a separate script in another php file (lets say Tool.php), so my form submission is action="Tool.php" method="post". I can't change this, because then the tool will no longer do what it needs to. Unless I can have multiple submit button that use different form elements (which I didn't think i could), then I wouldn't be able to do it this way. It would need to be done with a separate input type="button".

  4. #4
    Join Date
    Jun 2009
    You are saying that the next page to be served to the client (user) is not necessarily the same page with the form containing the checkboxes, but that it could be several pages later or even different days, but you want to remember what the user did so that any future serving of the page with the checkboxes is properly modified.

    Well, in that case, you need to store the user's settings on these checkboxes in a database, and then before that page of checkboxes is served to the user, you must identify the user and then check the database record on that user as to what his settings are. You would then serve the page with the checkboxes present or absent, based on what you found in the database record.

  5. #5
    Join Date
    Mar 2010
    alternatively, it would be fine if each box had its own remove link, like below

    []A remove
    []B remove
    []C remove

  6. #6
    Join Date
    Mar 2010
    well its an admin process being developed, so ideally when anyone changes the page, the actual html page should be altered permanently.

    Also, there is no database currently in use for this tool and I'd rather not have to set one up for such a small feature unless I really have to.

  7. #7
    Join Date
    Jun 2009
    You want some kind of persistence. An alternative is to set cookies to indicate the user's status then.

  8. #8
    Join Date
    Mar 2010
    the problem with cookies is that the administrator would have to log in from the same computer every time. the point is that person A deletes a checkbox from the page from a computer in London, and 5 minutes later person B logs in from Tokyo and the checkbox should still be deleted.

    Are you saying that there is no way to do this without a database?

  9. #9
    Join Date
    Mar 2010
    could something along the lines of the following script be used to perform the permanent removal?

    PHP Code:
    function remove($var){
    $doc = new DOMDocument();
    $doc loadHTMLFile("file.html");
    $formList $doc->getElementsByTagName('form');
    $form $formList->item(0);
    $removalNode null;
        for (
    $form->item($i)->nodeValue == $var){

  10. #10
    Join Date
    Jun 2009
    the problem with cookies is that the administrator would have to log in from the same computer every time. the point is that person A deletes a checkbox from the page from a computer in London, and 5 minutes later person B logs in from Tokyo and the checkbox should still be deleted.

    Are you saying that there is no way to do this without a database?

    If several users from different hosts are affecting the HTML document structure by their inputs, and the document is to be modified based on those inputs, then yes, the server has to keep track of this. It can keep a record in a file, or in its memory, or it can work with a database.

    And if several users can affect the status/structure of the HTML document, then you also need to worry about locking out the serving the document to user B if user A just requested it and is making changes that could create a confusing state of the document. This too is a problem with databases where two users try to write/update/change the same record in different ways (concurrency problem).

    As to your follow-up, while you can use DOM Document class methods in PHP to manipulate an HTML file for output (why?), think about where the value of parameter $var comes from for the call to remove().

  11. #11
    Join Date
    Mar 2010
    This appears to be the same thread as in the Javascript forum

    It looks to me you need a database as I described in the other thread before I stumbled across this one


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



X vBulletin 4.2.2 Debug Information

  • Page Generation 0.14499 seconds
  • Memory Usage 2,959KB
  • Queries Executed 15 (?)
More Information
Template Usage (34):
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (2)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (11)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (11)postbit
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (70):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates