Jump to content

Request.form


Akasha
 Share

Recommended Posts

HelloI have a button and when i push it, it must execute an sql update querythe query gets his information from a dropdown menu and a textfieldThat works all finebut somehow the &Request.Form("hoofdcategorie") functiongives back a strange result like

<option>,

for example i have choosen in my dropdown menu the item Groupthe query must be

UPDATE Hoofdcategorieen SET hoofdcat_name = 'test' WHERE (hoofdcat_name = 'Publications')

but instead he writes

UPDATE Hoofdcategorieen SET hoofdcat_name = 'test' WHERE (hoofdcat_name = 'Publications, ')

'Publications, 'the red part in the queryIs there sometime wrong with my Request.Form???thnxgreetzakasha

Link to comment
Share on other sites

this is the code after the submit

If Request.Form("rename") = "Rename item" Then   if Request.Form("hcat") <> "" then     if Request.Form("hoofdcategorie") <> "" then        sql ="UPDATE Hoofdcategorieen SET hoofdcat_name = '" &Request.Form("hcat")& "' WHERE (hoofdcat_name = '"&Request.Form("hoofdcategorie")&"')"        Response.Write(Sql)    end if   conn2.Execute(sql)end if

and this is my form

<form name='form' method='post' action='change_menu.asp'>  <tr>     <td>         <select name="hoofdcategorie" onchange="changeHoofdcat()">         <option value=''>--- Select a category ---         <%   	             'Recordset            set rs2 = Server.CreateObject("ADODB.recordset")            rs2.Open "SELECT * FROM Hoofdcategorieen WHERE hoofdcat_id > 1 ORDER BY hoofdcat_name ASC", conn2            'Fill variables with values            Do until rs2.EOF	if Request("HoofdCat") = rs2.fields("hoofdcat_name") then    Response.Write("<OPTION SELECTED value='" & rs2.fields("hoofdcat_name") & "'>" & rs2.fields("hoofdcat_name") & "</option>")	else    Response.Write("<OPTION value='" & rs2.fields("hoofdcat_name") & "'>" & rs2.fields("hoofdcat_name") & "</option>")	end if	rs2.movenext            Loop            rs2.close         %>         </select>      </td>     <%	       if Request("HoofdCat") <> "" then         'Recordset         set rs2 = Server.CreateObject("ADODB.recordset")         rs2.Open "SELECT c.*, h.hoofdcat_id FROM hoofdcategorieen h, categorieen c WHERE h.hoofdcat_name='"&Request("HoofdCat")&"' AND h.hoofdcat_id= c.hoofdcat_id ORDER BY c.cat_name ASC", conn2,1,1        'Fill variables with values         Hoofdcat = Request("HoofdCat")         if rs2.RecordCount = 0 then            Response.Write("<td><INPUT TYPE=""text"" NAME=""hcat"" SIZE=""20"" MAXLENGTH=""30""></td></tr>")         else           if request("Cat") = "" then              Response.Write("<td><INPUT TYPE=""text"" NAME=""hcat"" SIZE=""20"" MAXLENGTH=""30""></td></tr>")          end if          Response.Write("</tr><tr><td><select name=""hoofdcategorie"" onchange=""changeCat()""><option value=''>--- Select a category ---")          Do until rs2.EOF             if request("Cat") = rs2.fields("cat_name") then       Response.Write("<OPTION SELECTED value='" & rs2.fields("cat_name") & "'>" & rs2.fields("cat_name") & "</option>")             else      Response.Write("<OPTION value='" & rs2.fields("cat_name") & "'>" & rs2.fields("cat_name") & "</option>")             end if             rs2.movenext         Loop         rs2.close        Response.Write("</select></td>")      end if   end if %><%	   if Request("Cat") <> "" then     'Recordset      set rs2 = Server.CreateObject("ADODB.recordset")      rs2.Open "SELECT s.*, c.cat_id FROM categorieen c, subcategorieen s WHERE c.cat_name='"&Request("Cat")&"' AND c.cat_id= s.cat_id ORDER BY s.subcat_name ASC", conn2,1,1     'Fill variables with values     if rs2.RecordCount = 0 then       Response.Write("<td><INPUT TYPE=""text"" NAME=""categorie"" SIZE=""20"" MAXLENGTH=""30""></td></tr>")    else      if request("SubCat") = "" then        Response.Write("<td><INPUT TYPE=""text"" NAME=""categorie"" SIZE=""20"" MAXLENGTH=""30""></td></tr>")     end if     Response.Write("</tr><tr><td><select name=""subcategorie"" onchange=""changeSubCat()""><option value=''>--- Select a category ---")     Do until rs2.EOF        if request("SubCat") = rs2.fields("subcat_name") then         Response.Write("<OPTION SELECTED value='" & rs2.fields("subcat_name") & "'>" & rs2.fields("subcat_name") & "</option>")       else         Response.Write("<OPTION value='" & rs2.fields("subcat_name") & "'>" & rs2.fields("subcat_name") & "</option>")       end if       rs2.movenext    Loop    rs2.close    Response.Write("</select></td>")    if request("SubCat") <> "" then       Response.Write("<td><INPUT TYPE=""text"" NAME=""scat"" SIZE=""20"" MAXLENGTH=""30""></td>")   end ifend ifend if%>

Link to comment
Share on other sites

forgot something :)

</tr><tr>  <td><div align="left"></div></td>  <td colspan="2"><div align="left"></div></td></tr><tr>  <td class="p-content"><input name=rename type="submit" value="Rename item"></td>  <td class="p-content"><div align="right"><input type='button' onclick="window.location.href='../main.asp'" name=submit value='Cancel'></div>  </td></tr></form>

Link to comment
Share on other sites

okay i need you to do something and then tell me the result.On your update page change

If Request.Form("rename") = "Rename item" Then  if Request.Form("hcat") <> "" then    if Request.Form("hoofdcategorie") <> "" then       sql ="UPDATE Hoofdcategorieen SET hoofdcat_name = '" &Request.Form("hcat")& "' WHERE (hoofdcat_name = '"&Request.Form("hoofdcategorie")&"')"       Response.Write(Sql)   end if  conn2.Execute(sql)end if

to

dim rename = Request.Form("rename")dim hcat = Request.Form("hcat")dim hoofdcategorie = Request.Form("hoofdcategorie")dim hoofdcategorieen = Request.Form("hoofdcategorieen")Response.Write("rename="&rename&"<br>hcat="&hcat)Response.Write("<br>hoofdcategorie="&hoofdcategorie)Response.Write("<br>hoofdcategorieen="&hoofdcategorieen)'If Request.Form("rename") = "Rename item" Then'  if Request.Form("hcat") <> "" then'    if Request.Form("hoofdcategorie") <> "" then'       sql ="UPDATE Hoofdcategorieen SET hoofdcat_name = '" &Request.Form("hcat")& "' WHERE (hoofdcat_name = '"&Request.Form("hoofdcategorie")&"')"'       Response.Write(Sql)'   end if'  conn2.Execute(sql)'end if

You may want to copy and paste the old code into notepad so you can change it back easily later.Please post the output of this code. This will help determine whether it is a mistake in the form or the update page.

Link to comment
Share on other sites

This is the outputrename=Rename itemhcat=testhoofdcategorie=Group, hoofdcategorieen=

Link to comment
Share on other sites

I have found the problemMy first and second dropdown menu had the same nameso when he does the request form he will take the result from dropdown menu 1 and 2.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...