Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

asp and html form

  • 10-07-2007 12:48pm
    #1
    Registered Users, Registered Users 2 Posts: 36


    I am trying to display the old varible in the text field and after the user changes the varible in the text field, the new varible will display here

    please look at my code:

    <html>
    <body>
    <form action="a.asp" method="post">
    Your name: <input type="text" name="fname" size="20" value="<% response.Write(fname) %>" />
    <input type="submit" value="Submit" />
    </form>
    <%
    session fname
    fname=Request.Form("fname")
    If fname<>"" Then
    Response.Write("Hello " & fname & "!<br />")
    Response.Write("How are you today?")
    End If
    %>
    </body>
    </html>:confused:


Comments

  • Registered Users, Registered Users 2 Posts: 273 ✭✭stipey


    Without doing all the work for you... it looks like when you write the value into the textfield there is nothing there.

    This is because the value is empty.

    Why is it empty?


  • Registered Users, Registered Users 2 Posts: 4,468 ✭✭✭matt-dublin


    your codes back to front...

    you need to create the session at the top of the page
    code wrote:
    <html>
    <%session fname
    fname=Request.Form("fname")
    %>
    <head></head>
    <body>
    <form action="a.asp" method="post">
    Your name: <input type="text" name="fname" size="20" value="<% response.Write(fname) %>" />
    <input type="submit" value="Submit" />
    </form>
    <%
    If fname<>"" Then
    Response.Write("Hello " & fname & "!<br />")
    Response.Write("How are you today?")
    End If
    %>
    </body>
    </html>


  • Registered Users, Registered Users 2 Posts: 36 or89


    thats lookin good, thanks for the time and help


  • Registered Users, Registered Users 2 Posts: 4,468 ✭✭✭matt-dublin


    also i think it should be...
    code wrote:
    <%
    if request.form("fname") <> "" then
    session("fname")= Request.Form("fname")
    end if
    %>

    for an actual session

    what you've done there is just create a string

    so the rest of your code would look like as follows:
    code wrote:
    <%
    If fname<>"" Then%>
    Hello <%=session("fname")%>!<br />
    How are you today?
    <%
    End If
    %>

    and like this:
    code wrote:
    <form action="a.asp" method="post">
    Your name: <input type="text" name="fname" size="20" value="<%=server.htmlencode(session("fname"))%>" />
    <input type="submit" value="Submit" />
    </form>


Advertisement