#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2013
    Posts
    1
    Rep Power
    0

    Edit Form - Help


    Hi All,

    Not sure what I am doing wrong here - any help would be appreciated. I am having trouble with the EDIT function in the below code.

    Code:
    <!--#include file ="Conn.asp"-->							<!--Open our connection string-->
    
    <html>
    <head>
    		<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
    		<script src="js/jquery-ui.js"></script>
    		<link rel="stylesheet" href="./css/jquery-ui.css">
    			
    		<script>
    		$(function() {
    			$( "#accordion" ).accordion({
    			active: false,
    			heighStyle: "content",
    			collapsible: true    
    			});
    		  });
    		</script>
    
    		<script>
    		function setnotesection()
    		{
    			if (document.getElementById("editnotenumber").value!=''){
    				$('#<%=Request("editnotenumber")%>').click();
    			}
    		}
    		
    		function setdeletenumber(mynumber)
    		{
    			document.getElementById("deletenotenumber").value=mynumber;
    			document.getElementById("myaction").value='D';
    			noteform.submit();
    		}
    		
    		function seteditnumber(mynumber)
    		{
    			document.getElementById("editnotenumber").value=mynumber;
    			document.getElementById("myaction").value='E';
    			noteform.submit();
    		}
    		
    		</script>
    		
    		<script>
    			$(document).ready(function(){
    			$("input[type=reset]").on("click", function(){
    				//console.log($(this));								
    				//alert("Operation has been cancelled");
    			$( "#accordion" ).accordion({
    			active: false,
    			collapsible: true    
    			});        
    				});
    					});
    		</script>
    		
    </head>
    <body onload="setnotesection();">		
    <form name="noteform" method="post">
    <input type="hidden" name="myaction" id="myaction" value="">
    <input type="hidden" name="deletenotenumber" id="deletenotenumber" value="<%=request("deletenotenumber")%>">
    <input type="hidden" name="editnotenumber" id="editnotenumber" value="<%=request("editnotenumber")%>">
    <% 
    Dim Value
    Dim SecID
    
    		SecId = Request.Querystring("ID")
    		Response.write SecId & "<br>"
    			
    		if Request ("Submit")<>"" Then
    
    		sql="INSERT INTO HelpNotes (subject,note,sectionid)"		'Build the SQL statement
    		sql=sql & " VALUES ("
    		sql=sql & "'" & trim(Request("subject")) & "',"
    		sql=sql & "'" & trim(Request("note")) & "',"
    		sql=sql & "'" & trim(Request("SecId")) & "')"
    
    		'response.write sql & "<br>"
    		'response.end
    
    		conCurrent.Execute(sql)	 													'Execute the SQL statement      
    		conCurrent.close															'Close the connection string
    		set conCurrent = Nothing	
    	end if
    	
    	if Request("myaction") = "E" then
    																					'Get form values
    		mySubject = Request("txtsubject")											'Request the value entered on this form for the subject
    		myNote = Request("txtnote")													'Request the value entered on this form for the note
    			Set rstCurrent = Server.CreateObject("ADODB.recordset")					'Build the SQL = strSQL="update HelpNotes set x=x, y=y WHERE ID=" & request("editnotenumber")	
    			strSQL="UPDATE Helpnotes SET "
    			strSQL = strSQL & " subject='" & mySubject & "',"
    			strSQL = strSQL & "note='" & myNote & "'"
    			strSQL = strSQL & " WHERE ID ='" & request("editnotenumber") & "'"
    	'response.write sql & "<br>"
    	'response.end
    			conCurrent.Execute(strSQL)													'Execute the SQL statement      
    			conCurrent.close															'Close the connection string
    			set conCurrent = Nothing	
    	end if
    	
    	response.write "myaction: " & Request("myaction")
    	
    	if Request("myaction") = "D" then
    		
    		Set rstCurrent = Server.CreateObject("ADODB.recordset")							'Set up our Recordset	
    		strSQL="DELETE FROM HelpNotes WHERE ID=" & request("deletenotenumber")			'Build the SQL string
    		'response.write "strSQL: " & strSQL
    		'response.end
    		conCurrent.Execute(strSQL)														'Execute the SQL
    		conCurrent.close																'Close the connection
    		set conCurrent = Nothing
    		'Response.redirect "AddNote.asp"
    				
    	end if
    			
    	
    %>
    <div id="accordion">
    	<h3><img src="Images/notes_add.png">&nbsp;&nbsp;Add Note</h3></a>
    <div>
    <Style>textarea {resize: none;}</style>
    		<input type="hidden" name="SecId" value="<%=SecId%>">
           
                <label for="name">Subject:</label>
                <input type="text" class="input" name="subject" id="subject" tabindex="1"/>
             <br><br>
                <label for="Note">Note:</label>
                <textarea rows="15" cols="20" class="input1 textarea" name="Note" id="Note" tabindex="2">
                </textarea>
    		<BR><Br>
             <input type="submit" name="Submit"  class="button" value="Add Note" tabindex="3"/>
    		 <input type="reset" name="reset"  class="button" value="Cancel" tabindex="4"/> 	
    </div>
    
    <%
    ' The following is the code for the notes information.
    	Dim strSQL
    	Dim MyCon	
    	Set MyCon = Server.CreateObject("ADODB.Connection")
    	MyCon.open "Provider=SQLNCLI10;Server=Server-Database\SQL2005;Database=temp_testdb;Uid=sysad;Pwd=admin;"
    	
    		'myid = Request.QueryString("id")
    		'strSQL = "SELECT * FROM HelpNotes WHERE ID = '" & myid & "' ORDER BY notedate ASC"
    		strSQL = "SELECT * FROM HelpNotes ORDER BY notedate ASC"
    		Set rstCurrent = MyCon.Execute(strSQL)
    		if not rstCurrent.eof then
    		rstCurrent.movefirst
    			do while not rstCurrent.eof
    			
    				Response.Write "<h3><a id=" & rstCurrent("id") & " href=""#"">" & rstCurrent("Subject") & "</a></h3><div>"	
    				Response.write "<table>"
    				
    				if trim(request("editnotenumber"))=trim(rstCurrent("id")) then
    					
    					Response.write "<input type='hidden' name='SecId' value='('SecId')'>"
    					Response.write "<tr>"
    					Response.write "<td>Subject:</td>"
    					Response.Write "<tr></tr>"
    					Response.write"<td><input name='txtsubject' value=" & rstCurrent("subject") & " size='15'></td>"
    					Response.write "</tr><tr>"
    					Response.Write "<td>Note:</td>"
    					Response.write "</tr><tr>"
    					Response.write "<td><textarea rows='16' cols='16' name='txtnote'>" & rstCurrent("note") & "</textarea></td>"
    					Response.write "</tr>"
    					Response.Write "</table>"
    					Response.write "<br><center>"
    					Response.write "<input type='submit' class='button' name='Save' value='Save'>"
    					Response.write "<input type='reset' class='button' name='Delete' value='Cancel'>"
    					Response.write "</center>"
    				
    				else
    
    					Response.Write "<tr>"
    					Response.Write "<tr>"
    					Response.write rstCurrent("Note") & "<br><br>"
    					response.write "</tr><td>"
    					%>
    					<input type='button' class='button' name='Edit' value='Edit' onClick="seteditnumber(<%=rstCurrent("id")%>);" >
    					&nbsp;
    					<input type='submit' class='button' name='btnDelete' value='Delete' onClick="setdeletenumber(<%=rstCurrent("id")%>);" >
    					<%
    					Response.Write "</td>"
    					Response.Write "</tr>"
    					
    				end if
    				
    				Response.Write "</table>"
    				Response.Write "</div>"
    				
    				rstCurrent.movenext
    				
    			loop
    		
    		end if
    		rstCurrent.close
    		
       	MyCon.close
    	set MyCon = Nothing
    %>
    </form>
    </body>
    </html>
  2. #2
  3. No Profile Picture
    Grumpier old Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2003
    Posts
    14,453
    Rep Power
    4539
    You need to describe exactly what you're trying to accomplish, identify the problem you're having, explain what you've done in an attempt to find the source of the problem, show the relevant code snip, and tell what errors you receive and what line of code generates the error.
    ======
    Doug G
    ======
    Bartender to Rene Descartes "have another beer?" Descartes: "I think not" and he vanished.
    --Alfred Bester
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    120
    Rep Power
    10
    p[ost your error or more details of what does not work

IMN logo majestic logo threadwatch logo seochat tools logo