The code below is for an asp page opened from a parent window. The parent contains a form with drop down box, if the entry that the user requires is not on the drop down list, then the user can click a link to open this window and create a new option for the list. I don't want the hole form refreshed when the user closes the child window, just the options in the particular drop down box, the code below should work but isn't, the broblem appears to be with the javascript because the entry is going in to the database fine, the alert box is showing but the window isn't closing or updating the options.
It uses a select case because it holds a hole host of similar updates
Between body tags:
<% casenum=request.querystring("casenum"
QU="','"
Select case casenum
case 1: '----------- New Strategic Objective
response.write "<b>New Strategic Objective</b>"
response.write "<form action='New.asp?casenum=4' method='post'>"
response.write "<input type=text name=stratOb size=30>"
response.write "<input type='reset' name='Reset' value='Reset'>"
response.write "<input type='submit' value='Submit'>"
response.write "</form>"
case 4: '----Enter Strategic Objective into database
Response.write "<b></b><br><br>"
StratOb=request.form("StratOb"
createdby=request.servervariables("logon_user"
datein=now()
set rs=Server.CreateObject("adodb.Recordset"
'------ This is to figure out what the ID number is for the value
connectme="DSN=intranet"
sqlstmt= "SELECT stratobID from stratobSABD Order by stratobid"
rs.open sqlstmt, connectme
do while not rs.eof
stratobid=rs("stratobid"
rs.movenext
loop
set conn=server.createobject("adodb.connection"
conn.open "intranet"
sqlstmt = "INSERT INTO stratobSABD(stratob,createdby,datein)"
sqlstmt = sqlstmt & " VALUES ('" & stratob & QU & createdby & QU & datein& "')"
set rs=conn.execute(sqlstmt)
selectid="stratob"
idvalue=stratobid+1
showvalue=stratob
done=1
End Select
If done=1 then %> '---only pass the update if its been done
<script language=javascript>
function refreshlist(passedid)
{
alert("Got here"
;
var thebox=window.opener.getElementById(passedid);
thebox.options[thebox.options.length] = new Option('<%=idvalue & "','" & showValue %>');
window.close();
}
</script>
<div align=center><A HREF="javaScript:refreshlist('<%=selectid%>');">[Click here to close window]</A></div>
<% else
response.write "<div align=center><A HREF='JavaScript:window.close();'>[Click here to close window]</A></div>"
When the source code is viewed after the page is run, all variables are filled as I expect:
function refreshlist(passedid)
{
//alert("Got here"
;
var thebox=window.opener.getElementById(passedid);
thebox.options[thebox.options.length] = new Option('33','test test');
window.close();
}
</script>
<div align=center><A HREF="javaScript:refreshlist('stratob');">[Click here to close window]</A></div>
The more you know, the more you realise there is to know....
CCNA MCP
It uses a select case because it holds a hole host of similar updates
Between body tags:
<% casenum=request.querystring("casenum"
QU="','"
Select case casenum
case 1: '----------- New Strategic Objective
response.write "<b>New Strategic Objective</b>"
response.write "<form action='New.asp?casenum=4' method='post'>"
response.write "<input type=text name=stratOb size=30>"
response.write "<input type='reset' name='Reset' value='Reset'>"
response.write "<input type='submit' value='Submit'>"
response.write "</form>"
case 4: '----Enter Strategic Objective into database
Response.write "<b></b><br><br>"
StratOb=request.form("StratOb"
createdby=request.servervariables("logon_user"
datein=now()
set rs=Server.CreateObject("adodb.Recordset"
connectme="DSN=intranet"
sqlstmt= "SELECT stratobID from stratobSABD Order by stratobid"
rs.open sqlstmt, connectme
do while not rs.eof
stratobid=rs("stratobid"
rs.movenext
loop
set conn=server.createobject("adodb.connection"
conn.open "intranet"
sqlstmt = "INSERT INTO stratobSABD(stratob,createdby,datein)"
sqlstmt = sqlstmt & " VALUES ('" & stratob & QU & createdby & QU & datein& "')"
set rs=conn.execute(sqlstmt)
selectid="stratob"
idvalue=stratobid+1
showvalue=stratob
done=1
End Select
If done=1 then %> '---only pass the update if its been done
<script language=javascript>
function refreshlist(passedid)
{
alert("Got here"
var thebox=window.opener.getElementById(passedid);
thebox.options[thebox.options.length] = new Option('<%=idvalue & "','" & showValue %>');
window.close();
}
</script>
<div align=center><A HREF="javaScript:refreshlist('<%=selectid%>');">[Click here to close window]</A></div>
<% else
response.write "<div align=center><A HREF='JavaScript:window.close();'>[Click here to close window]</A></div>"
When the source code is viewed after the page is run, all variables are filled as I expect:
function refreshlist(passedid)
{
//alert("Got here"
var thebox=window.opener.getElementById(passedid);
thebox.options[thebox.options.length] = new Option('33','test test');
window.close();
}
</script>
<div align=center><A HREF="javaScript:refreshlist('stratob');">[Click here to close window]</A></div>
The more you know, the more you realise there is to know....
CCNA MCP