Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

variable undefined 1

Status
Not open for further replies.

thompom

Technical User
Dec 4, 2006
395
GB
hi - have the following javascript function that
closes the current window and refreshes the parent window
with a new querystring.
this all works fine but the variable x_datetxt is shown in the querystring as undefined instead of a date
which i have written to the page to make sure it does exist.

there is a twist to this because this variable is part of a loop. on the page, records are written from a recordset in a loop with buttons next to each one...
Code:
<img src="images/gotobut.gif" width="37" height="14" border="0" onclick="reload()" />
x_datetxt is different for each record and this may be what is causing the problem.

recordset loop
Code:
<%Do While (Not rs.Eof)
x_cusid = rs("cusid")
x_cusfname = rs("fname")
x_cuslname = rs("lname")
x_cusadd1 = rs("add1") 
x_cuspostc = rs("pcode") 
x_cushomtel = rs("hphone")
x_cusworktel = rs("wphone")
x_cusmobtel = rs("mphone")	
x_motbookid = rs("motbookid")
x_bookid = x_motbookid
x_motbookdate = rs("motbookdate")
x_datetxt = x_motbookdate
%>
<tr id="cusrow1">      
<td  bgcolor="#F5F5F5" class="mfitsml">
<%response.Write(x_datetxt)%>
</td>
        
<td bgcolor="#F5F5F5" class="mfitsml"><%response.Write(x_cusfname) & " " & (x_cuslname) & " " & (x_cuspostc)%></td>
		
<td bgcolor="#F5F5F5" class="mfitsml"> <div align="center"><img src="images/gotobut.gif" width="37" height="14" border="0" onclick="reload()" style='cursor: hand;'/>
</div></td>
</tr>
<%rs.MoveNext
Loop

function to close window and refresh parent
Code:
<script type="text/javascript">
function reload(){
        opener.location = opener.location + "&motdate=" + <%=Server.URLEncode(x_datetxt)%>
        self.close();
        }
</script>

 
[1]
><td bgcolor="#F5F5F5" class="mfitsml"> <div align="center"><img src="images/gotobut.gif" width="37" height="14" border="0" onclick="reload()" style='cursor: hand;'/>

[tt]<td bgcolor="#F5F5F5" class="mfitsml"> <div align="center"><img src="images/gotobut.gif" width="37" height="14" border="0" onclick="reload([blue]'<%=Server.URLEncode(x_datetxt)%>'[/blue])" style='cursor: hand;'/>[/tt]

[2] And then the reload() is scripted like this.
[tt]
function reload([blue]s[/blue]){
opener.location = opener.location + "&motdate=" + [blue]s[/blue];
self.close();
}
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top