opretter 2 poster i databasen!
HejNu har jeg props igen :D denne her gang er det en editor jeg har fået skaffet mig og for den til at tilføje til databasen.. også fint nok.. men den tilføjer altså 2 poster i stedet for en.. den laver nærmest et slags loop.. ved ik helt hvor fejlen ligger..
Her er koden:
if request.QueryString("site") = "newsite" then
Set Conn = Server.CreateObject("ADODB.Connection")
DSN = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("../db/database.mdb")
Conn.Open DSN
sql = "SELECT * FROM kategori"
set rsCat = Conn.execute(sql)
%>
<form name="editor" method="post" action="?site=todatabase">
<table id="table_2" width="400" border="0">
<tr>
<td>Kategori:</td>
<td>
<select name="form_cat6" id="form_cat">
<option value="">- Vælg katagori -</option>
<% DO WHILE NOT rsCat.EOF%>
<option value="<%=rsCat("ID")%>"><%=rsCat("kategorinavn")%></option>
<%rsCat.Movenext
Loop%>
</select></td>
</tr>
<tr>
<td>Rækkefølge:</td>
<td><label>
<input name="rekke" type="text" id="input_1" size="2" maxlength="4" />
</label></td>
</tr>
<tr>
<td>Sidenavn:</td>
<td><label>
<input name="form_name" type="text" id="input_1" />
</label></td>
</tr>
</table>
<br />
Indholdet af siden: <br />
<script LANGUAGE="JavaScript">
<!--
function button_over(eButton) {
eButton.style.cursor = 'pointer';
}
function button_out(eButton) {
eButton.style.borderColor = "#efedde";
}
function button_down(eButton) {
eButton.style.borderColor = "darkblue darkblue darkblue darkblue";
}
function button_up(eButton) {
eButton.style.borderColor = "darkblue darkblue darkblue darkblue";
eButton = null;
}
var isHTMLMode=false
function document.onreadystatechange() {
idContent.document.designMode = "On";
}
function cmdExec(cmd,opt) {
if (isHTMLMode) {
alert("Please uncheck 'Edit HTML'");
return;
}
idContent.document.execCommand(cmd,"",opt);
idContent.focus();
}
function setMode(bMode) {
var sTmp;
isHTMLMode = bMode;
if (isHTMLMode) {
sTmp=idContent.document.body.innerHTML;
idContent.document.body.innerText=sTmp;
toolbar.style.display = 'none';
} else {
sTmp=idContent.document.body.innerText;
idContent.document.body.innerHTML=sTmp;
toolbar.style.display = 'inline';
}
idContent.focus();
}
function createLink() {
if (isHTMLMode) {
alert("Please uncheck 'Edit HTML'");
return;
}
cmdExec("CreateLink");
}
function insertImageLink() {
if (isHTMLMode) {
alert("Please uncheck 'Edit HTML'");
return;
}
var sImgSrc=prompt("Insert Image File (You can use your local image file) : ", "http://www.microsoft.com/library/homepage/images/mslogo-blue.gif");
if(sImgSrc!=null) cmdExec("InsertImage",sImgSrc);
}
function insertImageLocal() {
if (isHTMLMode) {
alert("Please uncheck 'Edit HTML'");
return;
}
var sImgSrc = showModalDialog("selectImage.asp","","dialogHeight: 500px; dialogWidth: 400px; dialogTop: px; dialogLeft: px; edge: Raised; center: Yes; help: No; resizable: Yes; status: No;");
if(sImgSrc!=null) cmdExec("InsertImage",sImgSrc);
}
function uploadImages() {
var newWindow;
var props = 'scrollBars=yes,resizable=yes,toolbar=no,menubar=no,location=no,directories=no,width=500,height=500,top=100,left=200';
newWindow = window.open('upload.asp', 'Upload_Images_to_server', props);
}
function SubmitContent() {
document.editor.form_content.value = idContent.document.body.innerHTML;
document.editor.submit();
}
function tableDialog()
{
//----- Creates A Table Dialog And Passes Values To createTable() -----
var rtNumRows = null;
var rtNumCols = null;
var rtTblAlign = null;
var rtTblWidth = null;
showModalDialog("table.htm",window,"status:false;dialogWidth:16em;dialogHeight:13em");
}
function createTable()
{
//----- Creates User Defined Tables -----
var cursor = idContent.document.selection.createRange();
if (rtNumRows == "" || rtNumRows == "0")
{
rtNumRows = "1";
}
if (rtNumCols == "" || rtNumCols == "0")
{
rtNumCols = "1";
}
var rttrnum=1
var rttdnum=1
var rtNewTable = "<table border='1' align='" + rtTblAlign + "' cellpadding='0' cellspacing='0' width='" + rtTblWidth + "'>"
while (rttrnum <= rtNumRows)
{
rttrnum=rttrnum+1
rtNewTable = rtNewTable + "<tr>"
while (rttdnum <= rtNumCols)
{
rtNewTable = rtNewTable + "<td> </td>"
rttdnum=rttdnum+1
}
rttdnum=1
rtNewTable = rtNewTable + "</tr>"
}
rtNewTable = rtNewTable + "</table>"
idContent.focus();
cursor.pasteHTML(rtNewTable);
}
function doPreview(){
temp = idContent.document.body.innerHTML;
preWindow= open('', 'previewWindow', 'width=500,height=440,status=yes,scrollbars=yes,resizable=yes,toolbar=no,menubar=yes');
preWindow.document.open();
preWindow.document.write(temp);
preWindow.document.close();
}
function SetParagraph(name,value) {
idContent.focus();
if (value == '<body>')
{
idContent.document.execCommand('formatBlock','','Normal');
idContent.document.execCommand('removeFormat');
return;
}
idContent.document.execCommand('formatblock','',value);
}
-->
</script>
<table width="590" border="0" cellpadding="1" cellspacing="0">
<tr>
<td bgcolor="#CCCCCC">
<table width="590" border="0" cellpadding="0" cellspacing="0" bordercolor="#000000" id="table">
<tr id="toolbar">
<td width="750" align="top" bgcolor="#86B0C9">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="68"><select onChange="cmdExec('fontsize',this[this.selectedIndex].value);">
<option>Tekststørrelse</option>
<option value="2">Overskrift</option>
</select> </td>
<td width="375" height="22" nowrap bgcolor="#86B0C9"> <img class="cbtn" hspace="1" vspace="1" align=absmiddle src="images/imageUpload.gif" alt="Upload Images" onClick="uploadImages()" onMouseOver="button_over(this);" onMouseOut="button_out(this);" onMouseDown="button_down(this);" onMouseUp="button_up(this);"><img class="cbtn" hspace="1" vspace=1 align=absmiddle src="images/imageLocal.gif" alt="Insert Local Image" onClick="insertImageLocal()" onMouseOver="button_over(this);" onMouseOut="button_out(this);" onMouseDown="button_down(this);" onMouseUp="button_up(this);"><img class="cbtn" hspace="1" vspace=1 align=absmiddle src="images/imageLink.gif" alt="Insert Link to External Image" onClick="insertImageLink()" onMouseOver="button_over(this);" onMouseOut="button_out(this);" onMouseDown="button_down(this);" onMouseUp="button_up(this);"><img class="cbtn" hspace="1" vspace=1 align=absmiddle src="images/Link.gif" alt="Insert Link" onClick="cmdExec('createLink')" onMouseOver="button_over(this);" onMouseOut="button_out(this);" onMouseDown="button_down(this);" onMouseUp="button_up(this);">
</td>
</tr>
</table>
<table width="590" border="0" cellpadding="0" cellspacing="0" ID="Table1">
<tr>
<td height="22" nowrap> <img class="cbtn" hspace="1" vspace=1 align=absmiddle src="images/preview.gif" alt="Page Preview" onClick="doPreview();" onMouseOver="button_over(this);" onMouseOut="button_out(this);" onMouseDown="button_down(this);" onMouseUp="button_up(this);"><img class="cbtn" hspace="1" vspace=1 align=absmiddle src="images/Cut.gif" alt="Cut" onClick="cmdExec('cut')" onMouseOver="button_over(this);" onMouseOut="button_out(this);" onMouseDown="button_down(this);" onMouseUp="button_up(this);"><img class="cbtn" hspace="1" vspace=1 align=absmiddle src="images/Copy.gif" alt="Copy" onClick="cmdExec('copy')" onMouseOver="button_over(this);" onMouseOut="button_out(this);" onMouseDown="button_down(this);" onMouseUp="button_up(this);"><img class="cbtn" hspace="1" vspace=1 align=absmiddle src="images/Paste.gif" alt="Paste" onClick="cmdExec('paste')" onMouseOver="button_over(this);" onMouseOut="button_out(this);" onMouseDown="button_down(this);" onMouseUp="button_up(this);"><img class="cbtn" hspace="1" vspace=1 align=absmiddle src="images/Undo.gif" alt="Undo" onClick="cmdExec('Undo')" onMouseOver="button_over(this);" onMouseOut="button_out(this);" onMouseDown="button_down(this);" onMouseUp="button_up(this);"><img class="cbtn" hspace="1" vspace=1 align=absmiddle src="images/redo.gif" alt="Redo" onClick="cmdExec('Redo')" onMouseOver="button_over(this);" onMouseOut="button_out(this);" onMouseDown="button_down(this);" onMouseUp="button_up(this);"> </td>
<td width="2"><img src="images/vertical_line.gif" width="2" height="22"></td>
<td nowrap><img class="cbtn" hspace="1" vspace=1 align=absmiddle src="images/Bold.gif" alt="Bold" onClick="cmdExec('bold')" onMouseOver="button_over(this);" onMouseOut="button_out(this);" onMouseDown="button_down(this);" onMouseUp="button_up(this);"><img class="cbtn" hspace="1" vspace=1 align=absmiddle src="images/Italic.gif" alt="Italics" onClick="cmdExec('italic')" onMouseOver="button_over(this);" onMouseOut="button_out(this);" onMouseDown="button_down(this);" onMouseUp="button_up(this);"><img class="cbtn" hspace="1" vspace=1 align=absmiddle src="images/under.gif" alt="Underline" onClick="cmdExec('underline')" onMouseOver="button_over(this);" onMouseOut="button_out(this);" onMouseDown="button_down(this);" onMouseUp="button_up(this);"><img class="cbtn" hspace="1" vspace=1 align=absmiddle src="images/Strikethrough.gif" alt="Strike-through" onClick="cmdExec('StrikeThrough')" onMouseOver="button_over(this);" onMouseOut="button_out(this);" onMouseDown="button_down(this);" onMouseUp="button_up(this);"><img class="cbtn" hspace="1" vspace=1 align=absmiddle src="images/Superscript.gif" alt="Superscript" onClick="cmdExec('SuperScript')" onMouseOver="button_over(this);" onMouseOut="button_out(this);" onMouseDown="button_down(this);" onMouseUp="button_up(this);"><img class="cbtn" hspace="1" vspace=1 align=absmiddle src="images/Subscript.gif" alt="Subscript" onClick="cmdExec('SubScript')" onMouseOver="button_over(this);" onMouseOut="button_out(this);" onMouseDown="button_down(this);" onMouseUp="button_up(this);"> </td>
<td width="2"><img src="images/vertical_line.gif" width="2" height="22"></td>
<td nowrap><img class="cbtn" hspace="1" vspace=1 align=absmiddle src="images/left.gif" alt="Justify Left" onClick="cmdExec('justifyleft')" onMouseOver="button_over(this);" onMouseOut="button_out(this);" onMouseDown="button_down(this);" onMouseUp="button_up(this);"><img class="cbtn" hspace="1" vspace=1 align=absmiddle src="images/Center.gif" alt="Center" onClick="cmdExec('justifycenter')" onMouseOver="button_over(this);" onMouseOut="button_out(this);" onMouseDown="button_down(this);" onMouseUp="button_up(this);"><img class="cbtn" hspace="1" vspace=1 align=absmiddle src="images/right.gif" alt="Justify Right" onClick="cmdExec('justifyright')" onMouseOver="button_over(this);" onMouseOut="button_out(this);" onMouseDown="button_down(this);" onMouseUp="button_up(this);"> </td>
<td width="2"><img src="images/vertical_line.gif" width="2" height="22"></td>
<td nowrap><img class="cbtn" hspace="1" vspace=1 align=absmiddle src="images/numlist.gif" alt="Ordered List" onClick="cmdExec('insertorderedlist')" onMouseOver="button_over(this);" onMouseOut="button_out(this);" onMouseDown="button_down(this);" onMouseUp="button_up(this);"><img class="cbtn" hspace="1" vspace=1 align=absmiddle src="images/bullist.gif" alt="Unordered List" onClick="cmdExec('insertunorderedlist')" onMouseOver="button_over(this);" onMouseOut="button_out(this);" onMouseDown="button_down(this);" onMouseUp="button_up(this);"><img class="cbtn" hspace="1" vspace=1 align=absmiddle src="images/inindent.gif" alt="Increase Indent" onClick="cmdExec('indent')" onMouseOver="button_over(this);" onMouseOut="button_out(this);" onMouseDown="button_down(this);" onMouseUp="button_up(this);"><img class="cbtn" hspace="1" vspace=1 align=absmiddle src="images/outdent.gif" alt="Decrease Indent" onClick="cmdExec('outdent')" onMouseOver="button_over(this);" onMouseOut="button_out(this);" onMouseDown="button_down(this);" onMouseUp="button_up(this);"> </td>
<td width="2"><img src="images/vertical_line.gif" width="2" height="22"></td>
<td nowrap><img class="cbtn" hspace="1" vspace=1 align=absmiddle src="images/HR.gif" alt="Insert Horizontal Rule" onClick="cmdExec('InsertHorizontalRule')" onMouseOver="button_over(this);" onMouseOut="button_out(this);" onMouseDown="button_down(this);" onMouseUp="button_up(this);"> </td>
</tr>
</table> </td>
</tr>
<tr>
<th id="idContent" bgcolor="#FFFFFF"><iframe frameborder="0" src="iframe_in.html" width="590" scrolling="auto" id="idContent" height="280"></iframe></th>
</tr>
<tr>
<td align="right" bgcolor="#FFFFFF">
<table border="0" cellpadding="0" cellspacing="0" align="left">
<tr>
<td class="body"><input name="form_content" type="hidden" value=""></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<p>
<label>
<input type="submit" name="Submit" value="Submit" onClick="SubmitContent();"/>
</label>
</p>
</form>
<%
'--------------------------------------------tilføjer siden--------------------------------------------------------------'%>
<%elseif request.QueryString("site") = "todatabase" then
Set Conn = Server.CreateObject("ADODB.Connection")
DSN = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("../db/database.mdb")
Conn.Open DSN
sql = "INSERT INTO menu (KID,menunavn,content,rekke) VALUES ("& request.Form("form_cat6") &",'"& request.Form("form_name") &"','"& request.Form("form_content") &"',"& request.Form("rekke") &") "
Conn.execute(sql)
response.Write "du har nu oprettet en side..."
%>
