I am using the code below to fill a select box but if I have no values I would like the select box to not show. I would also like the submit button (Next) to hide as well. How do I do this?
'*****************************************************************
'* Step 2: Get the Store the User would like to view
'*****************************************************************
Dim strFolder
Set strFolder = Request.Form("Folders")
set txtFirstFolderName = strFolder
'Response.Write "txtDivisionName = " & strfolder & ""
objPath = Server.MapPath("AR_documentation/" & strFolder)
Set objFSO = CreateObject("Scripting.filesystemObject")
Set objfolder1 = objFSO.Getfolder(objPath)
Set objFolder2 = objfolder1.Subfolders
selectbox="<select name=folders2>"
For Each f1 in objFolder2
selectbox=selectbox & "<option>" & f1.name
Next
selectbox=selectbox &"</select>"
response.write selectbox
set objfolder1=Nothing
set objFSO = Nothing
set objFolder2 = nothing
dim objPath2, fso, folder
'Set fso = Server.CreateObject("Scripting.FileSystemObject")
objPath2 = Server.MapPath("AR_documentation\" & strFolder)
Set FSO = CreateObject("Scripting.filesystemObject")
Set folder = FSO.Getfolder(objPath2)
'This works for the C Drive.
'Set folder = fso.GetFolder("C:\Inetpub\wwwroot\aresearch\AR_documentation\" & strFolder & "")
%>
<INPUT name=btnSubmit type=submit value=" Next >">
<%
Add a variable to say that there are variables in the loop like this:
objPath = Server.MapPath("AR_documentation/" & strFolder)
Set objFSO = CreateObject("Scripting.filesystemObject")
Set objfolder1 = objFSO.Getfolder(objPath)
Set objFolder2 = objfolder1.Subfolders
selectbox="<select name=folders2>"
Dim HasVals
HasVals = False
For Each f1 in objFolder2
selectbox=selectbox & "<option>" & f1.name
HasVals = True
Next
selectbox=selectbox &"</select>"
response.write selectbox
set objfolder1=Nothing
set objFSO = Nothing
set objFolder2 = nothing
Then check the value when writing the select and the submit:
<%
If HasVals then
%>
<SELECT id=select1 name=select1 onChange="javascript:window.open(this.value,'groovywindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,height=' + WinHeight + 'width=' + WinWidth + 'copyhistory=no')">
'*****************************************************************
'* Step 2: Get the Store the User would like to view
'*****************************************************************
'******************
Dim selectbox
selectbox = ""
'******************
Set strFolder = Request.Form("Folders")
set txtFirstFolderName = strFolder
'Response.Write "txtDivisionName = " & strfolder & ""
objPath = Server.MapPath("AR_documentation/" & strFolder)
Set objFSO = CreateObject("Scripting.filesystemObject")
Set objfolder1 = objFSO.Getfolder(objPath)
Set objFolder2 = objfolder1.Subfolders
selectbox="<select name=folders2>"
For Each f1 in objFolder2
selectbox=selectbox & "<option>" & f1.name
Next
selectbox=selectbox &"</select>"
set objfolder1=Nothing
set objFSO = Nothing
set objFolder2 = nothing
dim objPath2, fso, folder
'Set fso = Server.CreateObject("Scripting.FileSystemObject")
objPath2 = Server.MapPath("AR_documentation\" & strFolder)
Set FSO = CreateObject("Scripting.filesystemObject")
Set folder = FSO.Getfolder(objPath2)
'This works for the C Drive.
'Set folder = fso.GetFolder("C:\Inetpub\wwwroot\aresearch\AR_documentation\" & strFolder & "")
'******************
if selectbox <> "" then
response.write selectbox
%>
<INPUT name=btnSubmit type=submit value=" Next >">
<%
end if
'******************
Use a simple counter and if the counter value is set then write the selest otherwise leave it llike this
dim counter
counter=0
For Each f1 in objFolder2
counter=counter+1
selectbox=selectbox & "<option>" & f1.name
Next
if counter>0 then
response.write selectbox
end if
and then with submit button use respose.write after this
Set FSO = CreateObject("Scripting.filesystemObject")
Set folder = FSO.Getfolder(objPath2)
'This works for the C Drive.
'Set folder = fso.GetFolder("C:\Inetpub\wwwroot\aresearch\AR_documentation\" & strFolder & "")
like this
if counter>0 then
response.write "<INPUT name=btnSubmit type=submit value=' Next >'>"
end if
FOllowing on from the earlier comment, you can hide the submit also like this:
If HasVals then
%>
<INPUT name=btnSubmit type=submit value=" Next >">
<%
End if
0
flfmmqpAuthor Commented:
Some times the answer is so simple you just have a hard time figuring it out in your own code mess. Thanks for the help.
0
Question has a verified solution.
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
objPath = Server.MapPath("AR_documen
Set objFSO = CreateObject("Scripting.fi
Set objfolder1 = objFSO.Getfolder(objPath)
Set objFolder2 = objfolder1.Subfolders
selectbox="<select name=folders2>"
Dim HasVals
HasVals = False
For Each f1 in objFolder2
selectbox=selectbox & "<option>" & f1.name
HasVals = True
Next
selectbox=selectbox &"</select>"
response.write selectbox
set objfolder1=Nothing
set objFSO = Nothing
set objFolder2 = nothing
Then check the value when writing the select and the submit:
<%
If HasVals then
%>
<SELECT id=select1 name=select1 onChange="javascript:windo
<%End if%>