27. februar 2001 - 09:04Der er
17 kommentarer og 1 løsning
check box again :)
hey there
I have a check box that i use in my database I have with the help of eksperten got it to work on my asp page where it only shows those news items that are set to True. so far so good :) However now I need a little more help :P I have another asp page that inserts into a database heres the db connection now <% Response.Buffer = True FUNCTION fixQuotes( theString ) fixQuotes = Replace( theString, \"\'\", \"\'\'\" ) END FUNCTION news_name = Request( \"news_name\" ) news = Request( \"news\" ) authour = Request( \"authour\" ) email = Request( \"email\" ) publish = Request( \"publish\" ) Set Con = Server.CreateObject( \"ADODB.Connection\" ) DBPath = \"DBQ=\" & server.mappath(\"../media.mdb\") Con.Open \"DRIVER={Microsoft Access Driver (*.mdb)}; \" & DBPath IF Request.Servervariables(\"Content_Length\") > 0 THEN Sql = \"INSERT INTO news (dato, news_name, news, authour, email, publish) VALUES(\'\" & Date() & \"\',\'\" & fixQuotes( news_name ) & \"\',\'\" & fixQuotes( news ) & \"\',\'\" & fixQuotes( authour ) & \"\',\'\" & fixQuotes( email ) & \"\',\'\" & fixQuotes( publish ) & \"\')\" Con.Execute Sql Response.Write \"<table valign=top align=center width=750 cellpadding=5 cellspacing=0><tr><td align=center id=td_noborder_color><b><font size=3 color=red>Nyheden er nu tilføjt til databasen</font></b></td></tr></table>\"
END IF
%> publish is a checkbox and the form I use also has a checkbox called publish blah blah blah .... But what i was wondering is this how should my Sql look or what syntax should I use with publish Any ideas would as usual me welcome Guzzie
Is dato a text fielt or Date field. In the insert into you have \'Date()\' indication the field is a text field. If its a Date field remove the \'\' or use # insted of \'. VALUES(#\"&Date()&\"#,
Hey There publish is a True/Flase and dato is a date field its always worked fine the script has only started retuning errors since I inserted publish ;( Guzzie
/tpiil It kan be on/off or True/Flase I use this SQLstmp = \"SELECT * FROM news where publish = True ORDER BY dato ;\" on another asp page and it works fine Guzzie
btw dudal I was thinking that If I have an asp page that takes the contents of the database and puts them in a form then the normal value=\"<%=rs(\"publish\")%>\" does not work hmmm if you can help I would appreciate it I can start a new question if need be :( sorry about all the bother but I just have not worked with check boxes before Guzzie
:) me try that I was thinking like this hihi <INPUT TYPE=\"checkbox\" VALUE=\"<% if publish = True Then publish = True else publish = False End If %>\" NAME=\"publish\">
<INPUT TYPE=\"checkbox\" VALUE=\"True\" NAME=\"publish\" <% if rs(\"Publish\") = \"True\" Then %>CHECKED<% end if %>>
thanks again dudal
Guzzie
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.