473,320 Members | 1,945 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

keep the values when it redirect the same page

Hi,

I have a question.

I made the create the new user form.

Expand|Select|Wrap|Line Numbers
  1.  <script language="javascript"> 
  2.  
  3. function submitFrm()
  4. {
  5. document.submitform.action="complete.asp"
  6. document.submitform.submit();
  7. }
  8. function Validate()
  9. {
  10. var username = document.submitform.username.value;
  11. var password = document.submitform.password.value;
  12. var email = document.submitform.email.value;
  13. var str = ""
  14.  
  15. if (username=="")
  16. {str="Username";}
  17. if (password=="")
  18. {str=str + "\nPassword";}
  19. if (email=="")
  20. {str=str + "\nE-Mail";}
  21.  
  22. if (username=="" || password=="" || email=="")
  23. { alert("Please Fill out the following field:\n\n" + str);}
  24. else {return submitFrm();}
  25. }
  26. </script>
  27.  
  28. <form name="submitform" method="post" action="" OnSubmit="Validate()">
  29. <center>
  30. <table border=2>
  31. <tr><td>First Name:</td><td><input type="text" name="fname" size="32" /></td></tr>
  32. <tr><td>Last Name:</td><td><input type="text" name="lname" size="32" /></td></tr>
  33. <tr><td>Sex:</td><td><input type="radio" name="sex" value="Male">Male</input>
  34. <input type="radio" name="sex" value="Female">Female</input></td></tr>
  35. <tr><td>Username:</td><td><input type="text" name="username" size="32" /></td></tr>
  36. <tr><td>Password:</td><td><input type="password" name="password" size="32" /></td></tr>
  37. <tr><td>E-Mail:</td><td><input type="text" name="email" size="32" /></td></tr>
  38. <tr><td></td><td><center><input type="submit" value="Submit" /><input type="reset" value="reset" /></center></td></tr>
  39. </table>
  40. <%
  41. if request.querystring("new")="exists" then
  42. Response.Write("Username already exists in database.")
  43. end if
  44. %>
  45.  
It works fine, but I want to keep back the Firstname, lastname, sex, and e-mail values. How can I keep the values once it redirect the newuser page.

Because, if there is one invalide value, then it will redirect the same page and remove all values I input.

How can I keep firstname, lastname, sex, and e-mail values?
Thanks.
Apr 15 '06 #1
5 4518
can u tell what u want to do ..
whether u want to post the data to nextpage
r else u want to check the use input data..
tell me in detail...
with regards
meenu
Jul 26 '06 #2
iam_clint
1,208 Expert 1GB
Based on the title of this thread
Expand|Select|Wrap|Line Numbers
  1. <%
  2. dim name
  3. name = Request("name")
  4. %>
  5. First Name: <input type="text" value="<%=name%>">
  6.  

or have no actuall submit button take action and onsubmit out of the form and use a button instead of a submit button and use on click so when you click it, it validates then sends the information otherwise you will stay on the same page and the javascript should display the errors without any refreshing done.
this will keep the values in the text field as the previous submitted form, if this wasn't what your are looking for then please rephrase your question.
Jul 26 '06 #3
hi...
save the following code as html file and test it in your local server...

<
Expand|Select|Wrap|Line Numbers
  1.  html> 
  2. <head>
  3. <title>Untitled Document</title>
  4. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  5. </head>
  6. <SCRIPT LANGUAGE=javascript>
  7. function fndelete()
  8.  
  9. {
  10. if (document.form.category.value=="")
  11. {
  12. alert("Please select values !");
  13. document.form.category.focus();
  14. return false;
  15. }
  16. if (document.form.sname.value=="")
  17. {
  18. alert("Content Field is Empty !");
  19. document.form.sname.focus();
  20. return false;
  21. }
  22. if (document.form.style.value=="")
  23. {
  24. alert("Content Field is Empty !");
  25. document.form.style.focus();
  26. return false;
  27. }
  28.  
  29.  
  30.  
  31. if (document.form.price.value=="")
  32. {
  33. alert("Content Field is Empty !");
  34. document.form.price.focus();
  35. return false;
  36. }
  37. if (document.form.shpcost.value=="")
  38. {
  39. alert("Content Field is Empty !");
  40. document.form.shpcost.focus();
  41. return false;
  42. }
  43.  
  44.  
  45. return true;
  46. }
  47. </SCRIPT>
  48.  
  49.  
  50.  
  51. <body bgcolor="#000000" text="#000000">
  52. <div align="center"> <p>&nbsp;</p><p><font color="#FF9900" size="3" face="Arial, Helvetica, sans-serif"><b>Tshirt 
  53. &nbsp;Entry</b></font></p>
  54.  
  55. <form name="form" method=post action="insert.asp" onsubmit="return fndelete();"> 
  56. <table width="44%" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="41%" height="25"> 
  57. <div align="left"><font color="#CCCCCC" face="Arial, Helvetica, sans-serif" size="2">Category</font></div></td><td width="59%" height="25"> 
  58. <font color="#CCCCCC" face="Arial, Helvetica, sans-serif" size="2">
  59.  
  60. <SELECT NAME="category">
  61. <option value="cooltshirt">cooltshirt</option>
  62. <option value="funnytshirt">funnytshirt</option>
  63. <option>Beefy-T Youth</option>
  64. <option>Beefy-T Adult Long Sleeve </option>
  65. <option>Playwear Toddler</option>
  66. <option>Playwear Infant </option>
  67. <option>Playwear Infant Creeper</option>
  68. <option>Ultimate Crew Sweatshirt</option>
  69. <option>3/4 Sleeve Raglan </option>
  70. </SELECT></font></td></tr><TR> 
  71. <TD WIDTH="41%" HEIGHT="25"> <DIV ALIGN="left"><FONT COLOR="#CCCCCC" FACE="Arial, Helvetica, sans-serif" SIZE="2">Name</FONT></DIV></TD><TD WIDTH="59%" HEIGHT="25"> 
  72. <FONT COLOR="#CCCCCC" FACE="Arial, Helvetica, sans-serif" SIZE="2"> <INPUT TYPE="text" NAME="name"> 
  73. </FONT></TD></TR><TR> <TD WIDTH="41%" HEIGHT="25"> <DIV ALIGN="left"><FONT COLOR="#CCCCCC" FACE="Arial, Helvetica, sans-serif" SIZE="2">Style</FONT></DIV></TD><TD WIDTH="59%" HEIGHT="25"> 
  74. <FONT COLOR="#CCCCCC" FACE="Arial, Helvetica, sans-serif" SIZE="2"> <SELECT NAME="style"><OPTION>mens</OPTION><OPTION>womens</OPTION><OPTION>kids</OPTION></SELECT></FONT></TD></TR><TR> 
  75. <TD WIDTH="41%" HEIGHT="25"> <DIV ALIGN="left"><FONT COLOR="#CCCCCC" FACE="Arial, Helvetica, sans-serif" SIZE="2">Color</FONT></DIV></TD><TD WIDTH="59%" HEIGHT="25"> 
  76. <FONT COLOR="#CCCCCC" FACE="Arial, Helvetica, sans-serif" SIZE="2"> <INPUT TYPE="text" NAME="color"> 
  77. </FONT></TD></TR><TR> <TD WIDTH="41%" HEIGHT="25"> <DIV ALIGN="left"><FONT COLOR="#CCCCCC" FACE="Arial, Helvetica, sans-serif" SIZE="2">Size</FONT></DIV></TD><TD WIDTH="59%" HEIGHT="25"> 
  78. <FONT COLOR="#CCCCCC" FACE="Arial, Helvetica, sans-serif" SIZE="2"> <SELECT NAME="size">
  79. <option>S</option>
  80. <option>M</option>
  81. <option>L</option>
  82. <option>XL</option>
  83. <option>XXL</option>
  84. </SELECT></FONT></TD></TR><TR> 
  85. <TD WIDTH="41%" HEIGHT="25"> <DIV ALIGN="left"><FONT COLOR="#CCCCCC" FACE="Arial, Helvetica, sans-serif" SIZE="2">Quantity</FONT></DIV></TD><TD WIDTH="59%" HEIGHT="25"> 
  86. <FONT COLOR="#CCCCCC" FACE="Arial, Helvetica, sans-serif" SIZE="2"> <SELECT NAME="qty">
  87. <option>1</option>
  88. <option>2</option>
  89. <option>3</option>
  90. <option>4</option>
  91. <option>5</option>
  92. <option>6</option>
  93. <option>7</option>
  94. <option>8</option>
  95. <option>9</option>
  96. <option>10</option>
  97. </SELECT></FONT></TD></TR><TR> 
  98. <TD WIDTH="41%" HEIGHT="25"> <DIV ALIGN="left"><FONT COLOR="#CCCCCC" FACE="Arial, Helvetica, sans-serif" SIZE="2">Price</FONT></DIV></TD><TD WIDTH="59%" HEIGHT="25"> 
  99. <FONT COLOR="#CCCCCC" FACE="Arial, Helvetica, sans-serif" SIZE="2"> <INPUT TYPE="text" NAME="price"> 
  100. </FONT></TD></TR><TR> <TD WIDTH="41%" HEIGHT="25"> <DIV ALIGN="left"><FONT COLOR="#CCCCCC" FACE="Arial, Helvetica, sans-serif" SIZE="2">ShippingCost</FONT></DIV></TD><TD WIDTH="59%" HEIGHT="25"> 
  101. <FONT COLOR="#CCCCCC" FACE="Arial, Helvetica, sans-serif" SIZE="2"> <INPUT TYPE="text" NAME="shpcost"> 
  102. </FONT></TD></TR><TR> <TD WIDTH="41%" HEIGHT="25"> <DIV ALIGN="left"><FONT COLOR="#CCCCCC" FACE="Arial, Helvetica, sans-serif" SIZE="2">Image</FONT></DIV></TD><TD WIDTH="59%" HEIGHT="25"> 
  103. <FONT COLOR="#CCCCCC" FACE="Arial, Helvetica, sans-serif" SIZE="2"> <INPUT TYPE="file" NAME="image"></FONT></TD></TR><TR> 
  104. <TD WIDTH="41%" HEIGHT="25"> <DIV ALIGN="left"><FONT COLOR="#CCCCCC" FACE="Arial, Helvetica, sans-serif" SIZE="2">Description</FONT></DIV></TD><TD WIDTH="59%" HEIGHT="25"> 
  105. <FONT COLOR="#CCCCCC" FACE="Arial, Helvetica, sans-serif" SIZE="2"> <INPUT TYPE="text" NAME="descp"> 
  106. </FONT></TD></TR><TR> <TD WIDTH="41%" HEIGHT="25"> <DIV ALIGN="left"><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2" COLOR="#CCCCCC">Pattern</FONT></DIV></TD><TD WIDTH="59%" HEIGHT="25"> 
  107. <FONT COLOR="#CCCCCC" FACE="Arial, Helvetica, sans-serif" SIZE="2"> <INPUT TYPE="text" NAME="pat"> 
  108. </FONT></TD></TR><tr><td colspan="2"><DIV ALIGN="CENTER"><FONT COLOR="red" SIZE="2" FACE="bolditalic"><B><FONT COLOR="red" SIZE="2" FACE="bolditalic"><INPUT TYPE="submit" NAME= "a2" VALUE="insert" SIZE="4"></FONT></B></FONT></DIV></td></tr> 
  109. </table></form><p>&nbsp;</p><p>s</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p></div>
  110. </body>
  111. </html>
  112.  
Jul 27 '06 #4
Niheel
2,460 Expert Mod 2GB
Meenu,

Use the code tags , the " # " button to store code. Otherwise it disorts the page.

- KUB
Jul 27 '06 #5
hi KUB


how to do that...
i am new to this forum..
can u tell me how to do..
Jul 27 '06 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Anne | last post by:
hie there, i want to be able to pass multiple parameters to another page. currently, i am able to do so, but somehow i feel it is not the correct way to do it. below is part of what i have so far....
3
by: Peter Row | last post by:
Hi, I better get the background stuff out the way first, so here goes: - Porting a VB6 webclass app to VB.NET using HttpHandlers and FormsAuthentication - When someone visits my site...
2
by: Pete | last post by:
Hi all... I sincerly hope one of the MS guys can clear this up for me... First some background... Ok, I have a web site which is fully translatable into several languages. All the strings...
6
by: Nad | last post by:
Hello, In order to go back to the previous page from a page with possible postbacks I keep Request.Referrer in ViewState and then use it to redirect to the previous page. However I am losing all...
9
by: Adrian Parker | last post by:
We have a website that works everywhere but on a few PCs on this one site.. Asp.Net 1.1 Server = Windows 2003 Client = XP In the web.config we use - cookieless="false" in the browser settings...
2
by: KFactor | last post by:
Is it possible to pass form variables to a page on another server using response.redirect? Or is there a secure way of passing sensitive information from one site to another such as a userID? ...
3
by: Sharon | last post by:
hello all, I was successfull in passing one value from first webpage to second webpage, but not sure how to pass three textbox values from the first page to the second page. Below is the code i...
18
by: John | last post by:
Something strange has just started to happen as I have been developing a db application on a site. Suddenly a session variable has stopped working as I pass it from 1 page to another (I am sure it...
2
by: phpmagesh | last post by:
Hi to all, I am creating a registration page, like name, last name, Date of birth, ph number, address etc.. When i click submit button all the values are taking to validation page using POST...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.