SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Having problems with my function

    Basically what I'm doing is making a pop up calendar that'll be used to select a day.

    The calendar has text links, when clicked it runs my function.

    That function is suppose to parse the date and send it back to the parent window, put the focus on it, then close the window.

    However I'm getting this error when the function is called:
    Line: 30
    Char: 2
    Error: 'opener.document.req_info.select2' is not an object'
    Code: 0
    URL: http://localhost/pop_cal.jsp
    Here's the function
    Code:
    function select_date(clicked_date)
    {
    	var clicked_month;
    	var clicked_day;
    	var clicked_year;
    
    	clicked_month = clicked_date.substring(0,2);
    	clicked_day = clicked_date.substring(3,5);
    	clicked_year = clicked_date.substring(6,10);
    	// alert(clicked_month + '/' + clicked_day + '/' + clicked_year);
    
    	opener.document.req_info.select1.selectedIndex.value = clicked_month;
    	opener.document.req_info.select2.selectedIndex.value = clicked_day;
    	opener.document.req_info.select3.selectedIndex.value = clicked_year;
    	opener.focus();
    	window.close();
    }
    And this is how i'm calling it:
    Code:
    <TD VALIGN=MIDDLE class="tinytext2" nowrap id="reverse1" align="center" valign="middle" onMouseOver="this.style.backgroundColor='#6688AA'; this.style.cursor='hand';" onMouseOut="this.style.backgroundColor='#384D6C';" onClick="select_date(07-01-2003)">
    That date is dynamically generated.
    Last edited by Defender1; Aug 5, 2003 at 13:56.
    Defender's Designs
    I'm Getting Married!

    Not-so-patiently awaiting Harry Potter Book 7 *sigh*

  2. #2
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,236
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Make sure that your <select> is named "select2" and that your punctuation/casing is correct (i.e. make sure you didn't type in "Select2" by mistake).

  3. #3
    SitePoint Guru Vincent Puglia's Avatar
    Join Date
    Feb 2000
    Location
    where the World once stood
    Posts
    700
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    if Vinnie's suggestions don't work, follow this link:

    http://members.aol.com/grassblad/html/selPop.html

    It's a script/tutorial on appending data from child windows.

    Vinny
    Where the World Once Stood
    the blades of grass
    cut me still

  4. #4
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hrmm... I didn't put the right error, it says
    opener.document.req_info.select2.selectedIndex is not an object.
    Is that the right object to use to change a select box to a specific option?

    Also the form name, the select name, are all correct.
    Defender's Designs
    I'm Getting Married!

    Not-so-patiently awaiting Harry Potter Book 7 *sigh*

  5. #5
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, I can get it to set the month now, but day and year still stay blank, and i now get no JS error. Here's my code:
    Code:
    function select_date(clicked_date)
    {
    	//var splitArray = new Array();
    	var clicked_month;
    	var clicked_day;
    	var clicked_year;
    
    	clicked_month = clicked_date.substring(0,2);
    	clicked_day = clicked_date.substring(3,5);
    	clicked_year = clicked_date.substring(6,10);
    	alert(clicked_month + '/' + clicked_day + '/' + clicked_year);
    
    	opener.document.req_info.select1.value = clicked_month;
    	opener.document.req_info.select2.value = clicked_day;
    	opener.document.req_info.select3.value = clicked_year;
    //	opener.focus();
    //	window.close();
    
    }
    I commented out the focus and close just so i could test. With it uncommented it does the same thing.
    Defender's Designs
    I'm Getting Married!

    Not-so-patiently awaiting Harry Potter Book 7 *sigh*

  6. #6
    SitePoint Guru Vincent Puglia's Avatar
    Join Date
    Feb 2000
    Location
    where the World once stood
    Posts
    700
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    Without the html, no one can give you any definite answer. According to the function, you have 3 inputs of indeterminate type. Is that the case, and what type are they (select, checkbox, text) ?

    Vinny
    Where the World Once Stood
    the blades of grass
    cut me still

  7. #7
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well, i would have thought select1, select2, and select3 would have given that away.

    But js didn't like those names. I changed them to month, day, year and they work fine now.

    Thx anyway.
    Defender's Designs
    I'm Getting Married!

    Not-so-patiently awaiting Harry Potter Book 7 *sigh*


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
  •