开发者

retaining the form inputs on clicking the submit button

开发者 https://www.devze.com 2023-01-02 12:05 出处:网络
i have a form. the code is: <html> <body> <form method=\"post\" action=\"array.asp\"> <input type=\"text\" name=\"Req_id1\">

i have a form. the code is:

<html>  
<body>  
<form method="post" action="array.asp">  
<input type="text" name="Req_id1">  
Req_id:    
<input type="text" name="Req_id">  
<input type="submit" value="search" id=submit1 name=submit1>  
<select id="selFiles" name="selFiles" class="Select" style="width: 500px" tabindex="130">  
<%  

Dim req_id,myArray(11)  
req_id=Request.Form("Req_id")  

myArray(0) = "FCC_CITI_LONDON\FCC_V.FM_Release_5.0"  
myArray(1) = "FCC_CITIUSDDA\FC_UBS_V.UM_10.3.0.0.CitiU开发者_JS百科SDDA1.0"  
myArray(2) = "FCC_KorAm\Flexcube_V.CK_Release_5.0"  
myArray(3) = "FCC-CL\FCC-CL.1.1.1"  
myArray(4) = "Mayaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"  
myArray(5) = "Juneaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"  
myArray(6) = "Julyaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"  
myArray(7) = "Augustaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"  
myArray(8) = "Septemberaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"  
myArray(9) = "Octoberaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"  
myArray(10) = "Novemberaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"  
myArray(11) = "Decemberaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"  

Dim myArrResult  

myArrResult = Filter(myArray, req_id, True, vbTextCompare)  

Dim item  

For Each item In myArrResult  
     Response.Write("<option>" + item + "</option>")  
Next  

%>  
</select>  
</body>  
</html>  

in between the form there is an opption to search a string from the array. on clicking submit the result are shown in the drop-down box. but the problem is that i loose all the input entered in the form before. for ex:the first input box goes blank. how do i retain the previous inputs? i have been able to retain the inputs of text fields but unable to retain the input of text area.any help is really appreciated.


For textboxes you would simply do something such as what Thomask said above:

<input 
  type="text" 
  name="yourotherinput" 
  value="<%=Request.Form("yourotherinput")%>"
>

For a select you would do as follows:

<select name = "state">
<option value = "0" <% if Request.Form("state") = "" then response.write("selected")%>>Select One:</option>
<option  value="AL" <% if Request.Form("state") = "AL" then response.write("selected")%>> Alabama</option>
<option  value="AK" <% if Request.Form("state") = "AK" then response.write("selected")%>> Alaska </option>
<option  value="AR" <% if Request.Form("state") = "AR" then response.write("selected")%>> Arkansas</option>
</select>

One problem with what you are doing currently is that your option elements have no value...so there really is no way to compare them.

Also with your current method it would be simpler to just check which is current selected then as you are building your dynamic option buttons simple add " selected" before the closing of the opening tag.

[Edit] As Thomask pointed out below: To do this on a textarea you would do as follows:

<textarea name="comments" rows="2" cols="20">
<% if Request.Form("comments") = "" then response.write(Request.Form("comments"))%>
</textarea>

Hope this helps.


For simple textboxes, try something like this:

<input 
  type="text" 
  name="yourotherinput" 
  value="<%=Request.Form("yourotherinput")%>"
>

For checkbox and select controls you would need to do a little more work.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号