SitePoint Sponsor |
|
User Tag List
Results 1 to 7 of 7
Thread: Having problems with my function
-
Aug 5, 2003, 13:40 #1
- 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.jspCode: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(); }
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)">
Last edited by Defender1; Aug 5, 2003 at 13:56.
-
Aug 5, 2003, 14:22 #2
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).
-
Aug 5, 2003, 14:27 #3
- 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.
VinnyWhere the World Once Stood
the blades of grass
cut me still
-
Aug 6, 2003, 05:58 #4
- 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.
-
Aug 6, 2003, 06:21 #5
- 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(); }
-
Aug 6, 2003, 06:37 #6
- 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) ?
VinnyWhere the World Once Stood
the blades of grass
cut me still
-
Aug 6, 2003, 06:38 #7
- 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.
Bookmarks