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

asp and html form

Options
  • 10-07-2007 1:48pm
    #1
    Registered Users 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 Posts: 1,127 ✭✭✭smcelhinney


    you'll probably get someone else saying this to you far less eloquently, so...

    a) Variable is spelt as such.
    b) Use [ CODE ] [/ CODE ] tags

    Im no good at ASP, but what does
    session fname
    
    do?


  • Registered Users Posts: 14,761 ✭✭✭✭Winters


    I believe it creates a session with the value "fname"

    [edit] I was wrong :( [/edit]


  • Moderators, Politics Moderators Posts: 39,920 Mod ✭✭✭✭Seth Brundle


    Session fname doesn't do anything
    Session("fname") = Request.Form("fname") will set up a session variable with the passed form's fname's value


  • Registered Users Posts: 14,761 ✭✭✭✭Winters


    I havnt touched ASP in about 5 years so I am more than a little rusty :)


  • Registered Users Posts: 273 ✭✭stipey


    You posted this already - and I presume a Mod deleted it. (It is simplistic code and could suggest that you didn't RTFM or STFW before posting here).

    So, I'll point you in the right direction and leave you to work it out from there...

    At this line...
    <input type="text" name="fname" size="20" value="<% response.Write(fname) %>" />
    

    ... nothing gets written. This is not because the Response.Write call did not execute - it is because the fname variable does not hold a value. It is empty.

    The question is - why is it empty? Why hasn't it been populated?


  • Advertisement
  • Users Awaiting Email Confirmation Posts: 351 ✭✭ron_darrell


    I have to agree with Stipey on this, you obviously haven't put the work in and are now trying to meet a deadline. I'd even hazard a guess due to the simplicity of the code and question that this is homework or a small project for college. You need to go back to your course book or manual and start from the top. Try remembering a few simple things:

    1. You shouldn't reference a variable before you set it
    2. You can't drop variables in the middle of HTML and expect them just to write to the screen
    3. If you want your code to do something make sure that you've told it to do it - don't expect it just to know

    Coding is not easy to just pick up and it takes a certain type of person to 'get' it, but if you don't put in the work you will never if you have what it takes. Take it step by step, don't be afraid to make mistakes and if you have web access try sites like www.w3schools.com or www.aspfree.com for tips and suggestions.

    Best of luck.
    -RD


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


    fyi all

    this was a double post and was sorted yesterday...

    http://www.pie.boards.ie/vbulletin/showthread.php?t=2055118962


Advertisement