Connecting Tech Pros Worldwide Forums | Help | Site Map

if condition in asp

Newbie
 
Join Date: Oct 2007
Posts: 4
#1: Oct 26 '07
hi,
i facing a problem in asp

the code goes like this
thereare two different database.
i have to add multple combo in the page only if my one condition is true.

eg
Expand|Select|Wrap|Line Numbers
  1. var RepName;
  2.  
  3. RepName = "<%=ReportName%>"
  4.  
  5. <%
  6.  Set conn = Server.CreateObject("ADODB.Connection") 
  7.  conn.Open "'
  8.  Set rs = ""
  9.  
  10. If reportname = "ABC" then
  11.  
  12. %>
  13.  
  14. <table border="0" cellpadding="0" cellspacing="0" width="100%">
  15.  
  16. <tr>
  17.     <td class="filterCol1" width="27%">
  18.     <b>Select Agency  : </b></td> 
  19.     <td class="filterCol2" width="73%">    
  20.         <Select name = "xyz" multiple ="true">
  21.         <option value= "all" selected="yes">Select All</option>
  22. <%
  23.  
  24. Do while not rs.eof
  25. name = rs("name")
  26. %>
  27.  <option value="<%= name %>"></option>
  28. <%
  29.  rs.MoveNext
  30. loop
  31. rs.close
  32. set rs=nothing
  33. %>
  34.  
  35. </select>
  36.     </td>
  37. </tr>
  38. </table>
  39. <% End if%>

if i remove if condition then it is working fine, but when i insert if nothing is display
when i debug the code the condition is true than to the table with combo is not displayed.
is there any problem in if statement

jhardman's Avatar
Moderator
 
Join Date: Jan 2007
Location: logan, utah
Posts: 2,690
#2: Oct 26 '07

re: if condition in asp


I don't see any problems. for troubleshooting you can add an else clause
Expand|Select|Wrap|Line Numbers
  1. else
  2.    response.write "reportName: " & reportName & "<br>" & vbNewLine
  3. end if
What does this give you?

I would advise to keep capitalization consistant. Even though vbScript is not case sensitive I think it helps (you refer to both "reportname" and "ReportName") but I don't think that will make any difference.

Let me know if this helps.

Jared
Newbie
 
Join Date: Oct 2007
Posts: 4
#3: Oct 29 '07

re: if condition in asp


thanks for reply the problem has been resolved as the variable name was incorrect.

Well, i am facind one more problem can one page can have multple forms
and how to read that multple forms elements(combo)?
jhardman's Avatar
Moderator
 
Join Date: Jan 2007
Location: logan, utah
Posts: 2,690
#4: Oct 29 '07

re: if condition in asp


Yes, a page can have multiple forms, but as far as I know there is no way to submit more than one form at a time. Tell me what you are trying and maybe I can suggest an alternative.

Jared
Newbie
 
Join Date: Oct 2007
Posts: 4
#5: Oct 31 '07

re: if condition in asp


hi,
There are two forms in my asp page. one is having multiple elements like single combo, date etc. and other is having multple combo. On click of the submit button the all the value of both the forms pass to one page.
problem is that values of first forms are passed easily but other form which is having multple combo is not passed.
can you please help me? It's very urgent.
jhardman's Avatar
Moderator
 
Join Date: Jan 2007
Location: logan, utah
Posts: 2,690
#6: Oct 31 '07

re: if condition in asp


Quote:

Originally Posted by charmgirl

hi,
There are two forms in my asp page. one is having multiple elements like single combo, date etc. and other is having multple combo. On click of the submit button the all the value of both the forms pass to one page.
problem is that values of first forms are passed easily but other form which is having multple combo is not passed.
can you please help me? It's very urgent.

why can't you put them all in one form?

Jared
markrawlingson's Avatar
Moderator
 
Join Date: Aug 2007
Location: Bowmanville, Ontario
Posts: 329
#7: Oct 31 '07

re: if condition in asp


As Jared said, there is no way to submit two forms at one time, only one or the other. The information from the other form isn't being lost - it's just not being sent.

What that means, essentially, is that if you have two forms on your page - a submit button will only submit the information in its parent form, the other information will NOT be passed to asp in the Request.Form object and therefore you can't access it on the next page.

It would be like a University professor giving out 2 assignments. The next day I submit only 1 assignment - He hasn't received the other assignment so he can't mark me on it because i didn't submit it.

If you want the information in both forms to be accessible on the second page, you will need to have 1 form, not 2.

Sincerely,
Mark
Reply