Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    May 2012
    Posts
    25
    Thanks
    4
    Thanked 1 Time in 1 Post

    Updating a form value

    Hi All,

    I have a popup calendar that I want a user to be able to click a date and for it to update a field on the previous page.

    I've tried the following code:
    Code:
    <SCRIPT LANGUAGE="JavaScript">
    function updateDate(){
    	window.opener.document.getElementById(startdate).value = "12/05/12";
    	self.close();
        return false;
    }
    </SCRIPT>
    but when clicking on the date nothing at all happens.

    I'm trying to get it so that any part of the DIV can be clicked on and the field I want to update is startdate, the code I'm using inside my DIV tag is
    Code:
    onclick="updateDate()"
    I'm very new to javascript so probably doing something very stupid!

    Thanks in advance

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,300
    Thanks
    203
    Thanked 2,561 Times in 2,539 Posts
    Code:
    window.opener.document.getElementById("startdate").value = "12/05/12";
    If "startdate" is the id of a field then then is a literal which must be in quotes.

    All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • Users who have thanked Philip M for this post:

    probi (05-27-2012)

  • #3
    New Coder
    Join Date
    May 2012
    Posts
    25
    Thanks
    4
    Thanked 1 Time in 1 Post
    I knew it would be something stupid!!

    Thanks very much


  •  

    Posting Permissions

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