tags:

views:

38

answers:

2

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.CitiUSDDA1.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.

A: 

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.

thomask
yeah i already figured this out for text boxes. still trying for select controls
sushant
A: 

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.

David
@ David: thanx for the help. its working for the select controls. but i am still unable to get it for text area field. any suggestions?
sushant
<textarea> should behave exactly like <input type=text>, except that textarea's have no value attribute, the value goes inline.
thomask
Thomask is completely correct, I went ahead and amended my post to reflect his input.
David
sushant
@sushant That's really odd, I tried it on a test page here, I'm using IIS 7 here and it's working just fine. Check out this article, hopefully it helps: http://stackoverflow.com/questions/1363325/request-form-for-a-textarea-returns-bad-data
David