www.webdeveloper.com
Results 1 to 11 of 11

Thread: form values

  1. #1
    Join Date
    Jul 2003
    Posts
    19

    form values

    because im using session variables i need to be able to reset input values to "" and keep values in input if submit is clicked
    basically i need java script that will keep the users input values instead of deleting on submit

    was trying for

    function check()
    {
    document.frmJoinUs.lastname.value = <%=Session("LastName")%>
    } but this didnt work

  2. #2
    Join Date
    Jan 2003
    Location
    Texas
    Posts
    10,413
    The code you posted looks like it would work fine. If you have an example of this online, may I see the link to better asisst you?

    [J]ona
    Visit Slightly Remarkable to see my portfolio, resumé, and consulting rates.

  3. #3
    Join Date
    Jul 2003
    Posts
    19

    ok

    heres the link but i think it will time out - probably cant be seen outside of the university..
    what about my code - can i post that?

  4. #4
    Join Date
    Jul 2003
    Posts
    19

  5. #5
    Join Date
    Jan 2003
    Location
    Texas
    Posts
    10,413

    Re: ok

    Originally posted by Consuelo
    heres the link but i think it will time out - probably cant be seen outside of the university..
    what about my code - can i post that?
    Apparently, I cannot view the link "outside of the university." So, yes, please post your code.

    [J]ona
    Visit Slightly Remarkable to see my portfolio, resumé, and consulting rates.

  6. #6
    Join Date
    Jul 2003
    Posts
    19
    i got rid of the "=" in last name so the reset button would work but now if the user clicks submit the values also dissapear thats why im trying to use javascript to redisplay the users input after the submit

    <INPUT type="TEXT" name="firstname" size="20" MaxLength="20" value="<%=Session("FirstName")%>">&nbsp;
    Last Name:<FONT color='#ff0000'>*</FONT>
    <INPUT type="TEXT" name="lastname" size="20" MaxLength="20" value="<%Session("LastName")%>">

    **************


    <%@ language=VBScript %>
    <%
    option explicit
    Response.Buffer = true
    Response.Expires = 0
    'on error resume next
    '------------------------------------------------------------------------------
    ' file name JoinUs.asp
    ' Description :
    ' History:
    ' 2001-02-01 - HShi - created
    '------------------------------------------------------------------------------
    %>
    <!--#INCLUDE FILE="../lib/ut_utility.asp"-->
    <!--#INCLUDE FILE="./addDataToFile.inc"-->
    <%
    Dim f1
    Dim strCheck1,strCheck2,strCheck3,strCheck4, strCheck, strReSelect
    Dim strMessage

    Call Initialisation

    Const HTML_TEXTAREA_SIZE_LIMIT = 250

    If UCase(trim(Request.Form("cmdSubmit"))) = "SUBMIT NOW" Then


    Call AddFormData

    'Do user input and business rule validation
    If IsValidForm = False Then

    strMessage = "<font color='#ff0000'><BR><b>Please review the following details before re-submitting the application form</b>." & _
    strMessage & "<br></font>"
    Else

    addToTable()

    strMessage = "<font color='GREEN'><b>Thank you for your application. You will receive a confirmation email.</b></font><BR><BR>"
    strMessage = strMessage
    %>
    <!--#INCLUDE FILE="./createnewfile.inc"-->
    <%
    Dim fso,fn
    Dim strFileName

    strFileName = createnewfile
    fn = Server.MapPath(".")
    fn = fn & "\"
    fn = fn & strFileName & ".htm"
    Session ("fn") = "http://140.159.223.211/6814u01/lab3/" & strFileName & ".htm"

    Set fso = Server.CreateObject("Scripting.FileSystemObject")
    Set f1 = fso.CreateTextFile(fn, True)

    addDataToFile()

    Response.Redirect("./Acknowledgement.asp")

    End If
    End If

    %>
    <HTML>
    <HEAD>
    <TITLE>Join MyClub.com</TITLE>
    <STYLE>
    <!-- #include FILE="../includes/MyClub.css" -->
    </STYLE>
    <script language="JavaScript" src="../lib/mylab2.js">
    <!--
    function check()
    {
    document.frmJoinUs.lastname.value = <%=Session("LastName")%>
    }
    //-->
    </script>
    </HEAD>
    <body bgcolor="#FFFFFF" onLoad="MM_preloadImages('../images/myclub_logo_magenta.gIf','../images/aboutus_over.gIf','../images/joinus_over.gIf','../images/contactus_over.gIf')" leftmargin="0" topmargin="0">
    <!--#include FILE="../includes/myclub_menubar2.inc" -->
    <CENTER><H2>Online Membership Application Form</H2></CENTER>
    <P align="CENTER">

    <%
    If (UCase(trim(Request.Form("cmdSubmit"))) = "SUBMIT NOW" ) Then
    %>
    <table border="0" width="*" align="center">
    <tr>
    <td>&nbsp;</td>
    <td align="left"><font color='#ff0000'>
    <%=strMessage%>
    </font><BR>
    </td>
    <td>&nbsp;</td>
    </tr>
    </table>
    <%
    End If

    If UCase(trim(Request.Form("Reset"))) = "RESET" Then
    Session.Abandon
    Response.WriteLine("reset")
    'Session("FirstName") = ""
    'Session("LastName") = ""

    'Session("Phone") = ""
    'Session("Fax") = ""
    'Session("Email") = ""
    'Session("Mobile") = ""
    'Session("message") = ""
    'Session("Gender") = ""

    'Session("Hobby1") = ""
    'Session("Hobby2") = ""
    'Session("Hobby3") = ""
    'Session("Hobby4") = ""

    'Session("Occupation") = ""

    'Session("UserName") = ""
    'Session("password") = ""
    'Session("password2") = ""
    End If
    %>
    You can choose your favorite background color:<BR>
    <BUTTON onClick="document.bgColor='white'"> WHITE </BUTTON>
    <BUTTON onClick="document.bgColor='red'"> RED </BUTTON>
    <BUTTON onClick="document.bgColor='green'"> GREEN </BUTTON>
    <BUTTON onClick="document.bgColor='blue'"> BLUE </BUTTON>
    <BUTTON onClick="document.bgColor='yellow'"> YELLOW </BUTTON>
    <BUTTON onClick="var bg = prompt('Please enter your favorite color' , 'custom');document.bgColor=bg"> CUSTOM </BUTTON>
    <BR>
    <form method="post" action="<%=Request.ServerVariables("SCRIPT_NAME")%>"
    name="frmJoinUs" onSubmit="return confirmSubmit();">
    <TABLE>
    <TR align = "LEFT"><B>Fields marked with "<FONT color='#ff0000'>*</FONT>" are compulsory<B><TR>
    <TR>
    <TD align="RIGHT">First Name:<FONT color='#ff0000'>*</FONT>
    </TD>
    <TD>
    <INPUT type="TEXT" name="firstname" size="20" MaxLength="20" value="<%=Session("FirstName")%>">&nbsp;
    Last Name:<FONT color='#ff0000'>*</FONT>
    <INPUT type="TEXT" name="lastname" size="20" MaxLength="20" value="<%Session("LastName")%>">
    </TD>
    </TR>
    <TR>
    <TD align="RIGHT">
    Phone:<FONT color='#ff0000'>*</FONT>
    </TD>
    <TD colspan = "2">
    <INPUT type="TEXT" name="phone" size="15" MaxLength="10" value="<%Session("Phone")%>" ID="Text1">&nbsp;&nbsp;
    Fax:<INPUT type="TEXT" name="fax" size="15" MaxLength="10" value="<%Session("Fax")%>">&nbsp;&nbsp;
    Mobile:<INPUT type="TEXT" name="mobile" size="15" MaxLength="10" value="<%Session("Mobile")%>">
    </TD>
    </TR>
    <TR>
    <TD align="RIGHT">E-Mail address:<FONT color='#ff0000'>*</FONT></TD>
    <TD colspan = "2"><INPUT type="TEXT" name="email" size="30" MaxLength=30 value="<%Session("Email")%>"><TD>
    </TR>

    <%
    strReSelect = Session("Gender")
    If not len(trim(strReSelect)) > 0 then
    strReSelect = ""
    end If
    %>
    <TR>
    <TD align="RIGHT">Gender:</TD>
    <TD><INPUT type="RADIO" name="gender" value="Male"<%'ut_Checked("Male", strReSelect)%>>Male
    <INPUT type="RADIO" name="gender" value="Female"<%'ut_Checked("Female", strReSelect)%>>Female</TD>
    </TR>

    <TR>
    <TD align="RIGHT">Hobbies:</TD><TD>
    <%
    strCheck1 = Session("hobby1")
    If not len(trim(strCheck1)) > 0 then
    strCheck1 = ""
    end If
    strCheck2 = Session("hobby2")
    If not len(trim(strCheck2)) > 0 then
    strCheck2 = ""
    end If
    strCheck3 = Session("hobby3")
    If not len(trim(strCheck3)) > 0 then
    strCheck3 = ""
    end If
    strCheck4 = Session("hobby4")
    If not len(trim(strCheck4)) > 0 then
    strCheck4 = ""
    end If
    %>
    <INPUT type=CHECKBOX name="hobby1" value="Basketball" <%'ut_checked("Basketball", strCheck1)%>>&nbsp;Basketball&nbsp;

    <INPUT type=CHECKBOX name="hobby2" value="Golf" <%'ut_checked("Golf", strCheck2)%>>&nbsp;Golf&nbsp;

    <INPUT type=CHECKBOX name="hobby3" value="Swimming" <%'ut_checked("Swimming", strCheck3)%>>&nbsp;Swimming&nbsp;

    <INPUT type=CHECKBOX name="hobby4" value="Tennis" <%'ut_checked("Tennis", strCheck4)%>>&nbsp;Tennis&nbsp;
    </TD>
    </TR>


    <%
    strReSelect = Session("Occupation")
    If not len(trim(strReSelect)) > 0 then
    strReSelect = ""
    end If
    %>
    <TR>
    <TD align="RIGHT">Occupation:</TD>
    <TD><SELECT name="Occupation">
    <OPTION value="" <%'ut_Selected("", strReSelect)%>>[SELECT occupation]
    <OPTION value="Executive" <%'ut_Selected("Executive", strReSelect)%>>Executive
    <OPTION value="Professional" <%'ut_Selected("Professional", strReSelect)%>>Professional
    <OPTION value="Academic" <%'ut_Selected("Academic", strReSelect)%>>Academic
    <OPTION value="Technician" <%'ut_Selected("Technician", strReSelect)%>>Technician
    <OPTION value="Other" <%'ut_Selected("Other", strReSelect)%> >Other
    </SELECT>
    </TD>
    </TR>

    <TR>
    <TD align="RIGHT">Message (No more than 200 characters):</TD>
    <TD><TEXTAREA name="message" cols="30" rows="4" ><%Session("message")%></TEXTAREA><TD>
    </TR>

    <TR><TD colspan=3><hr size=0></TD></TR>

    <TR>
    <TD align="RIGHT">Preferred username:<FONT color='#ff0000'>*</FONT></TD>
    <td>
    <INPUT type=text name="UserName" size=20 maxlength=20 value="<%Session("UserName")%>">
    </TD>
    </TR>

    <TR>
    <TD align="RIGHT">Password:<FONT color='#ff0000'>*</FONT></TD>
    <TD><INPUT type=password name="password" size=20 maxlength=20 value="<%Session("password")%>"></TD>
    </TR>

    <TR>
    <TD align="RIGHT">Confirm Password:<FONT color='#ff0000'>*</FONT></TD><td >
    <INPUT type=password name="password2" size=20 maxlength=20 value="<%Session("password2")%>"></TD>
    </TR>

    <TR><TD colspan=3><hr size=0></TD></TR>
    </TABLE>

    <TABLE align="right">
    <TR>
    <TD><INPUT type="SUBMIT" name="cmdSubmit" value=" Submit Now " onClick = "check()" onClick = "messageFunction()"></TD>
    <TD><INPUT type="Reset" name = "Reset" value="Reset" id=Reset>
    </TD>
    <TD><FONT color='#ff0000'>**Warning: This button will delete all your input!</FONT>
    </TR>
    </TABLE>
    </FORM>
    </P>
    </BODY>
    </HTML>

    <%

    Sub Initialisation

    strCheck1 = ""
    strCheck2 = ""
    strCheck3 = ""
    strCheck4 = ""
    strCheck = ""
    strReSelect = ""
    strMessage = ""

    End Sub


    Sub AddFormData

    Session("FirstName") = trim(Request.Form("FirstName"))
    Session("LastName") = trim(Request.Form("LastName"))

    Session("Phone") = trim(Request.Form("Phone"))
    Session("Fax") = trim(Request.Form("Fax"))
    Session("Email") = trim(Request.Form("Email"))
    Session("Mobile") = trim(Request.Form("Mobile"))
    Session("message") = trim(Request.Form("message"))
    Session("Gender") = trim(Request.Form("Gender"))

    Session("Hobby1") = trim(Request.Form("Hobby1"))
    Session("Hobby2") = trim(Request.Form("Hobby2"))
    Session("Hobby3") = trim(Request.Form("Hobby3"))
    Session("Hobby4") = trim(Request.Form("Hobby4"))

    Session("Occupation") = trim(Request.Form("Occupation"))

    Session("UserName") = trim(Request.Form("UserName"))
    Session("password") = trim(Request.Form("password"))
    Session("password2") = trim(Request.Form("password2"))

    End Sub



    Function addToTable ()
    Dim strCon, Con, strSQL, strSQL1, strSQL2
    adds data to the database
    End Function

    Function IsValidForm()
    IsValidForm = True

    this function does server side validation
    End Function %>

  7. #7
    Join Date
    Jan 2003
    Location
    Texas
    Posts
    10,413
    Try putting it in quotes, like this:


    function check()
    {
    document.frmJoinUs.lastname.value = "<%=Session("LastName")%>";
    }


    [J]ona
    Visit Slightly Remarkable to see my portfolio, resumé, and consulting rates.

  8. #8
    Join Date
    Jul 2003
    Posts
    19
    that didnt work

  9. #9
    Join Date
    Jan 2003
    Location
    Texas
    Posts
    10,413
    Maybe apostrophes...


    function check()
    {
    document.frmJoinUs.lastname.value = '<%=Session("LastName")%>';
    }


    [J]ona
    Visit Slightly Remarkable to see my portfolio, resumé, and consulting rates.

  10. #10
    Join Date
    Jul 2003
    Posts
    19

    didnt work

    thanks for your help
    i was trying to add aditionaly functionality to an assignment but its due today so i think ill leave it

    hope u have a good day
    Consuelo

  11. #11
    Join Date
    Jan 2003
    Location
    Texas
    Posts
    10,413
    Sorry, you couldn't get it to work.

    [J]ona
    Visit Slightly Remarkable to see my portfolio, resumé, and consulting rates.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles