SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Guru johnjohn2's Avatar
    Join Date
    Apr 2004
    Location
    here
    Posts
    746
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    blanking out 2 form fields

    I have a date picker that inputs the date into a hidden field and also a non-hidden field in a form. Currently the non-hidden field is disabled so users can't manually edit the entry but must use the date picker instead. I'd like to have a link so users have the ability to erase their date entry if necessary. Is this possible with some sort of hyperlink that would blank out the two fields?

  2. #2
    SitePoint Addict
    Join Date
    May 2000
    Posts
    313
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <a href="javascript:void(0)" onClick="document.form_name.field_name.value='';document.form_name.field_name2.value=''">Click</a>

  3. #3
    SitePoint Guru johnjohn2's Avatar
    Join Date
    Apr 2004
    Location
    here
    Posts
    746
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Instead of the javascript void part I put in # to keep it from going to a new page. I was wondering if there's a way to put in # without the browser going to the top of the page again. When I click it it scrolls to the top of the page. Other than that it works great.

    Quote Originally Posted by requestcode
    <a href="javascript:void(0)" onClick="document.form_name.field_name.value='';document.form_name.field_name2.value=''">Click</a>

  4. #4
    SitePoint Addict
    Join Date
    May 2000
    Posts
    313
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could make is a function like this:
    function Init_fields() {
    document.form_name.field_name.value='';
    document.form_name.field_name2.value='';
    }

    and then call the function like this:
    <a href="javascript:Init_fields()">Click Me</a>


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
  •