adnan_rais
asked on
ASP Insert using the JavaScript Function
What I need is that as the page unloads(or get closed), it inserts all records into the database. The database is built in MS Access. I've even used a slight JavaScript within the code. What modification shall be made in the following code ... ????
<head>
<script language="JavaScript">
function goVal()
{
insertAll(document.forms[0 ].prod_par ent.value, document.f orms[0].pr od_child.v alue);
window.parent.close();
}
function insertAll(p,c)
{
// ----- ASP insert code to be placed here
}
</script>
</head>
<body>
<form name="sales" method=post action="Categories.asp">
FName:<input name="fname" size=20>
<br>LName:<input name="fname" size=20>
<br><input type=button value="Submit" onClick="goVal()">
</form>
</body>
Remember the ASP Insert Code must be placed in the function, insertAll().
<head>
<script language="JavaScript">
function goVal()
{
insertAll(document.forms[0
window.parent.close();
}
function insertAll(p,c)
{
// ----- ASP insert code to be placed here
}
</script>
</head>
<body>
<form name="sales" method=post action="Categories.asp">
FName:<input name="fname" size=20>
<br>LName:<input name="fname" size=20>
<br><input type=button value="Submit" onClick="goVal()">
</form>
</body>
Remember the ASP Insert Code must be placed in the function, insertAll().
ASKER
thats so simple alorentz........... isn't there another alternate ....????
>>thats so simple alorentz
WHy make it hard...
>>isn't there another alternate ....????
No, you cannot call ASP with Javascript.
WHy make it hard...
>>isn't there another alternate ....????
No, you cannot call ASP with Javascript.
ASKER
like such
onUnload="<script>EnterVal ues()</scr ipt>"
onUnload="<script>EnterVal
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
any idea...???
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
justinbillig - where does it say anything about this in the link?
Remote Scripting is a way to call server functions from the client.
It is IE only and it uses a java applet...
there are some other versions of remote scripting that claim to be cross browser but i have never used them so i dont know
http://www.ashleyit.com/rs/
It is IE only and it uses a java applet...
there are some other versions of remote scripting that claim to be cross browser but i have never used them so i dont know
http://www.ashleyit.com/rs/
Yes, I know that...but this was a ASP question. So I wasn't addressing Java.
Thanks.
Thanks.
no you see it uses a java applet you dont program the java applet someone else already has done it ( Microsoft to be exact ) ... its is an answer to your asp question
"ASP Insert using the JavaScript Function"
If you want to do that you can use remote scripting ...
you call an ASP function from javascript code
read throught that article and you'll see what i am saying
"ASP Insert using the JavaScript Function"
If you want to do that you can use remote scripting ...
you call an ASP function from javascript code
read throught that article and you'll see what i am saying
ASKER
I mafe the code look like such. How to make it executable???? If I check the string using alert function, it displays exact data but doesn't allow to inert the record into database. So any idea ???? The Java session wasn't clearly understood to me. So plz let me know what to change in the following code to allow the data to be entered within the database.
<script language="JavaScript">
function Insert_Prod(fname_,lname_)
{
var str = 'Conn.Execute("';
str += '<%="insert into ChildProdItems(FName,LName ) values('+part+','+child+') "%>';
str += '")'
<%=str%>
// alert(str);
}
</script>
<body onUnload="Insert_Prod('<%= Request("f name")%>', document.f orms[0].ln ame.value) ">
<form name=sales method=post>
</form>
</body>
<script language="JavaScript">
function Insert_Prod(fname_,lname_)
{
var str = 'Conn.Execute("';
str += '<%="insert into ChildProdItems(FName,LName
str += '")'
<%=str%>
// alert(str);
}
</script>
<body onUnload="Insert_Prod('<%=
<form name=sales method=post>
</form>
</body>
ASKER
Sorry the scripting code is as
<script language="JavaScript">
function Insert_Prod(fname_,lname_)
{
var str = 'Conn.Execute("';
str += '<%="insert into ChildProdItems(FName,LName ) values('+fname_+','+lname_ +')"%>';
str += '")'
<%=str%>
// alert(str);
}
</script>
<script language="JavaScript">
function Insert_Prod(fname_,lname_)
{
var str = 'Conn.Execute("';
str += '<%="insert into ChildProdItems(FName,LName
str += '")'
<%=str%>
// alert(str);
}
</script>
ASKER
any idea.........??? Why I'm not using XML and Java is that my Web Hosting doesn't support these both platforms. That's why I've to use the code using ASP and JavaScript
ASKER
Thanx alorentz..... Sorry to say I couldn't get ur code implemented. I've solved the matter in some other way. When I couldn't enter the recods on Unload action, I've to redirect the URL to another window and then get it closed as it loads. Anyhow I'll still grade u points as the solution was quite different from the question being asked. Thanx for all ur support guyz............
function insertAll(p,c)
{
window.open("submitrecords
}