dennisa Posted February 1, 2006 Share Posted February 1, 2006 when I want to insert a new record, or update the database, I just want ... uhh just look at my code...html>><html><body><h1>Adding_record</h1><hr>input new record<p><form method="POST" action="add_confirm.asp"><p>nip <input name="nip"><p>name <input name="name"><p><input type="Submit" value="ADD"></form></body></html>asp>><html><body><h1>add_Confirm</h1><hr><%on error resume nextset conn = Server.Createobject("ADODB.Connection")conn.Provider = "Microsoft.JET.OLEDB.4.0"conn.open server.Mappath("dbkelas.mdb")nip= request.form("nip")name= request.form("name")conn.execute "insert into tkelas(nip,name) values('"&nip&"','"&name&"')",recordsaffectedif err<>0 thenresponse.write("You dont have any permission to update the database")elseresponse.write(recordsaffected&" record was added")end ifconn.closeset conn=nothing%></body></html>nip=primary keyso you must notice that the fatal error is when I try to insert new record...if I only fill the name, the record will appear in my database... eventhough the nip=""(null). I dont want that happen!!what I want is, whenever the user do not put the nip, hence alert message will b displayed prompting the user to fill the nip... so every record in my db will have an nip...do you think that what I need is an event handler?? or do you have any other idea?? Link to comment Share on other sites More sharing options...
aspnetguy Posted February 1, 2006 Share Posted February 1, 2006 change this nip= request.form("nip")name= request.form("name")conn.execute "insert into tkelas(nip,name) values('"&nip&"','"&name&"')",recordsaffectedif err<>0 thenresponse.write("You dont have any permission to update the database")elseresponse.write(recordsaffected&" record was added")end if to nip= request.form("nip")name= request.form("name")if nip <> "" then conn.execute "insert into tkelas(nip,name) values ('"&nip&"','"&name&"')",recordsaffected if err<>0 then response.write("You dont have any permission to update the database") else response.write(recordsaffected&" record was added") end ifelse response.write("you must give a value for nip")end if Link to comment Share on other sites More sharing options...
dennisa Posted February 2, 2006 Author Share Posted February 2, 2006 change thisnip= request.form("nip")name= request.form("name")conn.execute "insert into tkelas(nip,name) values('"&nip&"','"&name&"')",recordsaffectedif err<>0 thenresponse.write("You dont have any permission to update the database")elseresponse.write(recordsaffected&" record was added")end if to nip= request.form("nip")name= request.form("name")if nip <> "" then conn.execute "insert into tkelas(nip,name) values ('"&nip&"','"&name&"')",recordsaffected if err<>0 then response.write("You dont have any permission to update the database") else response.write(recordsaffected&" record was added") end ifelse response.write("you must give a value for nip")end if <{POST_SNAPBACK}> thanks asp net guy!!!yes, any other way??because actually I want the pop up message appear if I press the submit button so the user dont bother to go to the asp page.....the html page will prompt the user to fill the nip field!! Link to comment Share on other sites More sharing options...
aspnetguy Posted February 2, 2006 Share Posted February 2, 2006 <html><head><script>function onFormSubmit(){ var nip = document.getElementById('nip'); if(nip.value == "") { alert('you must give nip a value'); return false; }}</script><body><h1>Adding_record</h1><hr>input new record<p><form method="POST" action="add_confirm.asp" onsubmit="javascript:return onFormSubmit()"><p>nip <input name="nip" id="nip"><p>name <input name="name"><p><input type="Submit" value="ADD"></form></body></html> That should work. Link to comment Share on other sites More sharing options...
dennisa Posted February 3, 2006 Author Share Posted February 3, 2006 <html><head><script>function onFormSubmit(){ var nip = document.getElementById('nip'); if(nip.value == "") { alert('you must give nip a value'); return false; }}</script><body><h1>Adding_record</h1><hr>input new record<p><form method="POST" action="add_confirm.asp" onsubmit="javascript:return onFormSubmit()"><p>nip <input name="nip" id="nip"><p>name <input name="name"><p><input type="Submit" value="ADD"></form></body></html> That should work. <{POST_SNAPBACK}> thanks youre really helpful....another problem comes... Link to comment Share on other sites More sharing options...
aspnetguy Posted February 3, 2006 Share Posted February 3, 2006 glad I could help Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now