|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
not getting proper input from asp form
following is the simple asp code I am just trying to get input from user but not getting the value of the first fiels that "tname" can somebody help me out of this mess
<% if Request.ServerVariables("REQUEST_METHOD")="POST" then Dim tname, discription tname = Request.Form("tname") ' this is the line but it is not getting the value of tname from the form discription = Request.Form("S1") Session("filename")=tname Session("filedis")=discription Response.Redirect("rah.asp") Response.End End If %> <html> <head> <title>upload</title> <script Language="javascript"> function confirm_entry() { if (document.MyForm.tname.value="") { alert("Please enter the Name of the Update") return (false); } return (true); } </script> </head> <body bgcolor="f1f1f1"> <form method="post" action="issupring.asp" name="MyForm" onSubmit="return confirm_entry(this.form);"> <p align="center"> <font face="Verdana" size="1"><b> Update Name</b>: <input type="text" name="tname"> </font> <p align="center"><font face="Verdana" size="1"><b> Description</b> : <textarea rows="2" name="S1" cols="20"></textarea></font></p> <p> </p> <p align="center"> <font face="Verdana" size="1"> <input type="submit" name="submit" value="Submit"> </font> </html>tname = Request.Form("tname") tname = Request.Form("tname") tname = Request.Form("tname")
__________________
Rahul Small things lead to perfection and perfection is not a small thing. |
|
#2
|
|||
|
|||
|
Why
are you checking to see *how* your <form>...</form> is posted ?
Why do this: if Request.ServerVariables("REQUEST_METHOD")="POST" then Didn't *you* the programmer decided *how* you would post your <form>...</form> ? If your *NOT* sure how the <form>...</form> was posted then simply use the Request() without using the .Form or .QueryString Then, make some debugging. For example: <% Dim tname, discription tname = Trim(Request.Form("tname") ) 'FOR DEBUG ONLY 'Response.Write "-->" & tname & "<--<hr>" 'Response.End 'You can even make some validation! If tname = "" Then Response.Write "No value entered for tname!" Response.End ' or use Response.Redirect End If . . . REST OF CODE... . . . %> Tell me if I'm wrong but what *I* think your doing is: You have a page called *issupring.asp* that submits to *itself* You then retrieve the values and put them into *Session* variables. Once this is done you make a redirect to *rah.asp* If that is correct my question to you is why ? Why not make your <form>...</form> action attribute go to the rah.asp ? And at the *top*/*beginning* of the rah.asp page simply do: ----rah.asp <% Dim tname Dim discription tname = Trim(Request.Form("tname")) discription = Trim(Request.Form("S1")) 'FOR DEBUG ONLY 'Response.Write "-->" & tname & "<--<hr>" 'Response.Write "-->" & discription & "<--<hr>" 'Response.End 'Validation if empty If tname = "" Then .....CODE... End If 'Ok so now we know the variable *tname* holds something.. 'Put the value into the session variable Session("filename")=tname '-------continue loading the rest of rah.asp------------- %> Hope this helps! Sincerely Vlince |
|
#3
|
|||
|
|||
|
Hello Vlince,
Thanx for the reply You have understood the problem correctly, and I think that the suggesstion given by you will work. Actually I am a bit new in asp coding, I will try your suggessions and reply you back Thanx once again |
|
#4
|
|||
|
|||
|
Hello Vlince,
Sorry, to say that it will not Work because I am using Request.binary in rah.asp so I can not use Request.form in that page so I have to do this in issupring.asp only. any new suggessions Thanx Rahul |
|
#5
|
|||
|
|||
|
ok
so continue with your first approach, the one where you make a redirect to rah.asp
There is no errors in the code you've showed in your first post, although you claim that there is no value inside the variable tname right? What does the Response.Write of the variable give you? <% Dim tname, discription tname = Trim(Request.Form("tname") ) 'FOR DEBUG ONLY Response.Write "-->" & tname & "<--<hr>" Response.End ...rest of code... %> What do you see between the --> and <-- on your browser? |
|
#6
|
|||
|
|||
|
nothing blank for tname but it gives value of description
I dont know why it is not taking the value of tname I must have messed woith the HTML code somewhere but I m unable to figure it out see if you can help thanx Rahul |
|
#7
|
|||
|
|||
|
try a simple example:
1) create an .asp page called page1.asp 2) create a <form>...</form> that as a method set to *POST* and an *action* attribute set to page1.asp 3) create one <textbox> called *tname* 4) create a <textarea> with the name *S1* 5) Add a <submit> button NOTE: Lose the onSubmit attribute for testing purposes only. Then copy the code you have and make a response.write of the variable tname and the description one. See the results... then, if it works, start adding your javascript again. |
|
#8
|
|||
|
|||
|
ok pal
I will try this thanx for the support |
|
#9
|
|||
|
|||
|
It is still not working
if you want I will attach rah.asp also please I need help I have to do it |
|
#10
|
|||
|
|||
|
still waiting for the answer can anybody there who can help
|
|
#11
|
|||
|
|||
|
Ok
I've copy/pasted the code from your *first* post and I tweaked it a bit. The changes I did are in bold.
Ok here, you can copy/paste this its tested and it works! ------------------------------------------------------------------------ <%@ Language=VBScript %> <%Option Explicit%> <%Response.Buffer = true%> <% If Request.Form("hidSubmit") = "1" Then Dim tname Dim discription tname = Trim(Request.Form("tname")) discription = Trim(Request.Form("S1")) Session("filename") = tname Session("filedis") = discription 'Response.Redirect("rah.asp") 'Response.End 'FOR DEBUG ONLY 'Response.Write "-->" & Session("filename") & "<--<hr>" 'Response.Write "-->" & Session("filedis") & "<--" 'Response.End End If %> <html> <head> <title>upload</title> <script Language="javascript"> function confirm_entry() { if (document.MyForm.tname.value == "") { alert("Please enter the Name of the Update") return (false); } return (true); } </script> </head> <body bgcolor="f1f1f1"> <form method="post" action="test.asp" name="MyForm" onSubmit="return confirm_entry(this.form);"> <input type="hidden" name="hidSubmit" value="1"> <p align="center"> <font face="Verdana" size="1"><b> Update Name</b>: <input type="text" name="tname"> </font> <p align="center"><font face="Verdana" size="1"><b> Description</b> : <textarea rows="2" name="S1" cols="20"></textarea></font></p> <p> </p> <p align="center"> <font face="Verdana" size="1"> <input type="submit" name="submit" value="Submit"> </font> </body> </html> A couple of things: First I've changed the action attribute of your <form>...</form> to test.asp and my page is named test.asp. So the idea is that the page submits to itself. Second, I've added a <hidden> field so that when the user clicks the <submit> button I know(at the top of the page) if the page has been submitted or not. I notice that your where doing/making a Response.End after your Response.Redirect "rah.asp". But it is *NOT* necessary because *NO CODE IS EXECUTED* after a Response.Redirect. For now, in the example, I've commented the two lines 'Response.Redirect("rah.asp") 'Response.End I've also added a FOR DEBUG ONLY section which makes a Response.Write of the two Session variables. You also had an error inside your javascript function you only had *one* equal sign but in fact you need *two* equal sign otherwise the <form>...</form> would *still* submit even if the <textbox> is equal to ""(empty string) NOTE: You might also want to check/search for a javascript trim() function cause the user could simply enter a space inside your textbox and bypass the javascript validation. Try it... Then inside the <form>....</form> I've added a <hidden> field that will use when the form is submitted. At last, I've added a </body> which was missing from your first post. Hope this helps! Sincerely Vlince |
|
#12
|
|||
|
|||
|
Thanx Vlince,
I will try it today and tell you the outcome. Vlince, it is working fine when I am just accessing issupring.asp means it is showing the all the values, but it is not taking the values in rah.asp, I will try the given steps if it will not work I will attach the rah.asp also thanx once again |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > not getting proper input from asp form |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|