Results 1 to 2 of 2

Thread: Not getting the form

  1. #1
    Join Date
    Nov 2006

    Question Not getting the form


    i have a strange behavior on my webpage on my local computer.
    i have 2 forms. One of them is defined as following:
    <form class='form-validate view' id='siteForm' name='siteForm' method='post' action='<?php echo $url; ?>' >
       <!-- blah, blah -->
       <a class="delete" href="#" title="Delete selected records" onclick="alert(document.siteForm.boxchecked.value);">
          <span class="trash-icon"></span>
       <!-- blah, blah -->													
       <input type="hidden" name="boxchecked" value="" />
    during runtime user can tick checkboxes and a javascript function updates the value of input field called boxchecked (this works very well)

    my problem:
    - if user click on the link, the alert message does not display any data... (the code on onclick is just temporary)

    if i want to retrieve the value and display it correctly, i must use:
    instead of:
    why ?
    it's like js is not able to find the siteForm form object

  2. #2
    Join Date
    Mar 2007
    The code you posted works - it shows a blank alert which is correct.

    document.siteForm addresses the form via the name attribute only.

    This works but is deprecated and should not be used. Then name attribute should only be applied the the elements of forms, not the <form> tag.

    document.getElementById('siteForm') is correct syntax for addressing an element by its ID.

    If you apply an onclick handler to a form element (not a link within the form),
    the handler can reference other elements directly by name (not ID), or via this.form.elementName

    Where used, return should be executed unconditionally and always as the last statement in the function.

    That's my signature, it's not part of the damn post!

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