Hide field if its empty

Hi all,
I am a relative newbie when it comes to writing ASP code and am struggling with something that I hope somebody out there will be able to help me with.
I have an ASP detail page that displays information from as Access 2003 database regarding orders. Only information from one order is displayed on a page at a time. Each order line has 5 text fields that can be used for descriptive purposes. However not every order line uses each of the 5 description lines. My detail page currently shows a table with a repeat region to list all of the lines on the order as follows:
<td>
<%=(SOLines.Fields.Item("Description1").Value)%><br>
<%=(SOLines.Fields.Item("Description2").Value)%><br>
<%=(SOLines.Fields.Item("Description3").Value)%><br>
<%=(SOLines.Fields.Item("Description4").Value)%><br>
<%=(SOLines.Fields.Item("Description5").Value)%>
</td>
This is fine and works a treat, however more often than not only 2, 3 or 4 of the text fields will be used which will mean that my web page displays blank lines.
I was hoping to be able to write some code that would not display the line if it was null or contains no data, so after much digging I came up with the following:
<td>
<%=(SOLines.Fields.Item("Description1").Value)%><br>
<% if (SOLines.Fields.Item("Description2").Value != "") {(SOLines.Fields.Item("Description2").Value);}%><br>
<% if (SOLines.Fields.Item("Description2").Value != "") {(SOLines.Fields.Item("Description3").Value);}%><br>
<% if (SOLines.Fields.Item("Description2").Value != "") {(SOLines.Fields.Item("Description4").Value);}%><br>
<% if (SOLines.Fields.Item("Description2").Value != "") {(SOLines.Fields.Item("Description5").Value);}%><br>
</td>
Unfortunately for me this doesn't work and after several hours of trying different configurations of brackets, semi-colons other exciting stuff I'm still no closer to achieving my goal.
I have also tried using the Show region server behavior, but this only seems to apply to an entire recordset, not individual fields.
Is there a kind and helpful soul out there who can point out the error of my ways?
Many thanks in advance,
Dan

Hi Bregent, thanks for the reply.
bregent wrote:
First, why are you using Javascript rather than VBScript?
Errr.... no idea. Thats what Dreamweaver has produced. Is it possible/acceptable/ethical to mix different coding languages in one page?
Since my original post I have modified the code so it now looks like this:
<td valign="top"><%=(SOLines.Fields.Item("Description1").Value)%>
          <% if (SOLines.Fields.Item("Description2").Value != "") { %>
               <br><%=(SOLines.Fields.Item("Description2").Value)%><br>
          <% } %>
          <% if (SOLines.Fields.Item("Description3").Value != "") { %>
               <%=(SOLines.Fields.Item("Description3").Value)%><br>
          <% } %>
          <% if (SOLines.Fields.Item("Description4").Value != "") { %>
               <%=(SOLines.Fields.Item("Description4").Value)%><br>
          <% } %>
          <% if (SOLines.Fields.Item("Description5").Value != "") { %>
               <%=(SOLines.Fields.Item("Description5").Value)%><br>
          <% } %>
          </td>
This will produce a box containing 5 lines. Say for example that my text fields 1,2 and 3 contain some text while 4 and 5 are blank the following results:
Description
Text line1
Text Line 2
Text Line 3
<blank line>
<blank line>
I have this morning tried checking for Null instead of "" as you suggested, and this seems to have solved my problem. So the code looks like this:
<td valign="top"><%=(SOLines.Fields.Item("Description1").Value)%>
           <% if (SOLines.Fields.Item("Description2").Value != null) { %>
                <br><%=(SOLines.Fields.Item("Description2").Value)%><br>
           <% } %>
           <% if (SOLines.Fields.Item("Description3").Value != null) { %>
                <%=(SOLines.Fields.Item("Description3").Value)%><br>
           <% } %>
           <% if (SOLines.Fields.Item("Description4").Value != null) { %>
                <%=(SOLines.Fields.Item("Description4").Value)%><br>
           <% } %>
           <% if (SOLines.Fields.Item("Description5").Value != null) { %>
                <%=(SOLines.Fields.Item("Description5").Value)%><br>
           <% } %>
          </td>
This produces exactly what I want:
Description
Text line1
Text Line 2
Text Line 3
Many thanks for posting.
I'm still interested to know what the advantages are of using VBScript though
Thanks again
Dan

Similar Messages

  • Setting input fields to an empty string BIG PROBLEM

    Hi Rob, thanks for your rerply, It makes sense alright, but I am using 2 seperate input fields. I have discovered what is causing the problem .
    After the user types into the inputfield and moves on to a different frame, I have set the input field to an empty string and this is what is causing the problem.
    I have tried setting the input field to an empty string in a movie script and on individual sprites and the first right answer is not excepted.I have to type in the right answer twice to get get a right response. I am actually using three seperate input fields in total, each with a different name and behavior. Even If I use one input field I still have the same problem. Its driving me crazey. Any Ideas.
    Anne

    I believe that the FIM Service always does trims on string, so you may be out of luck.
    What is your scenario / what are you trying to accomplish by setting a space in an attribute? A space is not an empty string in my definition.
    Regards, Soren Granfeldt
    blog is at http://blog.goverco.com | facebook https://www.facebook.com/TheIdentityManagementExplorer | twitter at https://twitter.com/#!/MrGranfeldt

  • HT4864 When trying to update my Mail Account Mailbox Behaviours settings, when I try to close the settings pane the following messages occur: Invalid Incoming Mail Server The "Incoming Mail Server" field cannot be empty. The incoming mail server box has p

    When trying to update my Mail Account Mailbox Behaviours settings, after making the changes when I try to close the settings pane the following messages occur: Invalid Incoming Mail Server The “Incoming Mail Server” field cannot be empty. The incoming mail server box has in light grey colour: p02-imap.mail.me.com in it and I cannot edit its content. Any ideas what is going on and how to fix it?

    Hi all,
    Mattreichenbach is probably on the right track here with a reset of settings.  I think I've determined the issue has to do with cached account information and inconsistencies for the account name.  This seems to crop up when I've changed my password and it hasn't propagated fully to all the servers, devices, certificates, etc.
    Hopefully many here are on their way to restoration of service by now but it's clear that a lot of people are having the same issues.  Very frustrating and definitely something Apple needs to resolve:  incoming mail server field grayed out, incorrect autopopulation of different fields, other unanticipated behaviors.  If you're still having issues, though, here's what worked for me...
    First, head to the iCloud preferences pane in System Configuration and choose "Sign Out".  When I did this it prompted me with a number of "are you sure" type questions about retaining information on my local machine.  I chose to delete/remove the info each time simply because it should all be restored by the cloud and I didn't want to risk a massive duplication of my data... I will say, I'm back up and running with no issues so I suspect you can make the same delete/remove choices...  But use your own judgment.  I don't want you to lose any data (ie.. please use care as you do this because I cannot bear the thought of causing anyone to experience the pain of data loss).
    Once you've signed out of iCloud, restart your system.  When you get back in, head to the Mail, Contacts and Calendars section of your System Preferences and add your account back by choosing the brushed aluminum "iCloud" button.  When it asks for your account name, use your @iCloud.com email address.  I am all but certain my issue had started because one of my devices (iPhone or whatever) had been set up with an email alias specified instead of my @iCloud.com address.
    Apple, if you're reading through any of these issues (there are TONS of users having this same problem).  Take note, that your icloud service somewhat frequently is not responding and yet tells the user that the password is wrong and this prompts people to be changing their passwords unnecessarily.  This has happened to me on numerous occasions.  Also, I noticed that last week's outage corresponded to a VERY similar outage exactly one year ago to the day.  Sounds like planned maintenance to me and I think you could do a better job notifying folks so we're not wasting HUGE amounts of time troubleshooting a problem that we have no hope of fixing.
    Hope that helps some of you!
    Terry Mullane
    Washington, DC

  • How to hide fields in Table maintenace screen

    I have created a view with table maintenance generator. I would like to hide some fields. With event I am able to fill in those fields but I want to hide those from screen.

    HI, 
    This is reff with ur below post, I have been stuck with same problem,
    I got your code, how its functioning, but didn't get get where i have to write it.
    plz tell me in brief.
    Thanks in Advance.
    Regards
    Vivek
    Re: How to hide fields in Table maintenace screen  
    Posted: Feb 6, 2009 11:42 AM   in response to: Aarti Ramdasi in response to: Aarti Ramdasi           
    Click to report abuse...             Click to reply to this thread      Reply
    Hi,
    You can hide the fields like this..
    For example
    select-options:
    s_carrid for spfli-carrid modif id gr1,
    s_connid for spfli-connid modif id gr1,
    s_cityto for spfli-cityto modif id gr2.
    I am going to hide last fied..To do this
    at selction-screen output.
    if s_carrid is initial or s_connid is initial.
    loop at screen.
    if screen-group1 CS 'GR2'.
    screen-active = 0.
    modify screen.
    endif.
    endloop.
    endif.
    whenever u click on any one of the field i.e. carrid or connid the third field will displayed.Otherwies the last field cityto is not visible initially
    Regards
    Kiran

  • Field Explorer is empty after establishing a connection to a SQL 2008 SP

    I am trying to create a report using a SQL Server 2008 stored procedure as the source of data using an ADO connection.
    The stored procedure is slightly odd, in that its building up the SQL as a string, Below is a snippet of the code to show what I mean. The reason for this is that I need to build up the WHERE clause dependign on user input.
         SELECT @var_query = 'SELECT  c_source,
            c_ccy,
            n_quantity,
           a_price,
           d_price,
           a_isd
                         FROM     ldsdbo.lds_testing_filter_data_vw WHERE'
         PRINT @var_query
         EXEC (@var_query)
    This runs fine in SQL Server, but when I try and use it in Crystal, the Database Field list is empty.
    Does anyone know whats going on, and how I can make this work?
    Thanks
    Nathan

    Well... Now I just feel obligated to reply...
    The key(s) to using an SP as your data source is to make sure that your SP does in fact return a single data set.
    So... begin by testing it in SSMS. If the following works in SSMS, then it should also work in CR...
    EXEC usp_MyStoredProcedure 'ParamValue1', 'PramValue2'
    ... note: the above example is based on the premise that the SP name is "usp_MyStoredProcedure" and you are tryig two pass 'ParamValue1' & 'PramValue2' as values...
    Obviously, you should use the actual SP name and any necessary test values if it has parameters.
    Assuming that the SP executes in SSMS AND returns a result set, you should be good to go in CR... Just do as Don mentioned and make sure you are using the NC10 drivers.
    If you are still getting stuck, remove the SP from the Database Expert and call the SP from a Command instead. It's easy to do as it allows you to use the exact syntax you used in SSMS. You'll just want to replace any hard coded values with CR parameters... (Just add the parameters to the parameter list of the command and reference them like this...
    EXEC usp_MyStoredProcedure '{?Parameter1}', '{?Parameter2}'
    HTH,
    Jason

  • HCM interactive Forms - hide fields and backend connection

    Hello,
    we plan to implement a personnel transfer workflow based on interactive forms. Because in one step the user should not be able to see a couple of fields, it is possible in interactive forms zu hide fields based on the users role?
    I read a lot the last days but what I still havent found out and I hope you can push me in the right direction is, how the connection between backend and Form is working.
    Inside of an example form and in the documentation is descriped to use this below code to implement a bushbutton and the send message to create a server round trip. But if I create 2 pushbuttons with the same code, how do I know which button was pressed? Or do I have to create my own events somewhere? Or is there only this one event and I have to set a hidden field with some value via javascript or formcalc to find out whats going on in the form?
    $record.CONTROL_PARAM.ISR_EVENT = "USER_EVENT_CHECK"
    ContainerFoundation_JS.SendMessageToContainer(event.target, "submit", "", "", "", "");
    best regards,
    Kai

    Hey Rajesh
    I'm not sure it will work - but its worth a try.
    Every time i wont to hide some subforms or UI elements - I determine them as "invisible" by default - and when the conditions are right - I turn them to "visible" (negatively way).
    Hopefully it will help you.
    Eyal

  • Grant Master field group control based on authorization - hide fields

    Hi,
    The Grant Master field group control settings are based on grant type settings. So you can hide fields and tabs etc based on the grant's lifecycle status.
    Does anyone know if this can be configured based on authorization objects / authorization roles?
    We wish certain fields to be hidden in all life cycle statuses for all general users, but for central finance users we wish those fields to be visible.
    There is a customizing transaction GMS103 in the SPRO/IMG path
    IMG > Public Sector Management > Grants Management > Grantee Management > Master Data > Grant > GM Grant Control : Field group for Authorizations
    The documentation for this transaction says:
    GM Grant Control: Field Group for Authorizations
    It is possible to group fields together for authorization purposes. Use this step to specify such groups in Grants Management (GM).
    Standard settings
    We deliver the groups you can enter here, as standard.
    Activities
    Choose New Entries and enter the ID for the group you want to add. When you save, the system displays the longer description for the group.
    Further notes
    Authorization to a group allows access to all the fields in the group for users with the appropriate authorization. Only allow access to those you know need it for the whole group.
    This table is empty on our system. Has anyone used this part of the customizing and can they let me know how it links into the basis roles / authorizations etc.
    Thanks
    Paul Abrahamson

    I found this authorization object F_GMGT_FDG
    The documentation for the authorization object states:
    Definition
    With this authorization object, you can define authorizations for individual field groups in grants management maintenance. You thereby define which fields in grant master maintenance can be maintained or viewed by a user.
    Notes
    This authorization is optional. You do not have to assign authorization if there are no field groups that require special protection and consequently no field groups requiring authorization were defined in Customizing.
    Defined fields
    The object consists of the fields "Field group" and "Activity":
    Field group
    Here you define which field groups require authorization.
    Activity
    Here you define which activities are permitted:
    02 = Change
    03 = Display
    * = All activities
    Procedure
    Proceed as follows if you want to use this authorization:
    1. Determine the field groups of the fields that you want to protect.
    2. In Customizing, define that these field groups require authorization.
    3. For each field group, define the authorization that you wish to assign to selected users.
    4. Assign this authorization using the corresponding profile.
    I'll try this out and update this message again later

  • Reading T588M hide fields for MOLGA/feature/variable key & HIDE custom flds

    Hi
        I have requirement to  read hide fields from  T588M . As we can hide filed in T588m and we already have written a program in which it called certain feature from PE03 for IT0002  and hide the filed based on the user authorization . Now I have introduce another field which some how the same as in SAP standard screen , for some good reason and according to business process it was not full filling the requirements . So I introduce another field.  Now what we want  in PBO of IT enhancement  it stop certain users to see that fields using feature ( Tr.Pe03 Feature “p0002” ) . In feature we have programmed that it call our customized program and check the authorization  as mention earlier .
    Here’re my questions
    -     Do you guys have any other good option to control that?
    -     If some how I manage to read feature using FM “HR_FEATURE_BACKFIELD” in PBO
    -      After reading feature I am accessing the table T588m to make sure for certain feature which field is hide or not  as in table T588m I can see the fields like ‘’’+’-‘’’,’ , how can I make sure which field is refer to what …  I also find the FMS
    -      HRPAD00SCREENCONTROL           
    -      HR_READ_T588M_WITH_PME04       
    -      HR_T588M_CUSTOMIZING           
    -      HR_T588M_GET_DYNPRO            
    -      HR_T588M_GET_FIELDATTRIBUTES   
    -      HR_T588M_SAVE   
    -     But the above Fm also not fulfilling my requirement.  As I was thinking that I read the fields , SAY if standard  field is hide in  the feature , I can loop at my screen and  hide the custom field which I enhanced in IT0002.
    Right now I’m debugging the  standard code how its reads the T558M , and I got some clue .. But it looks like long path I mean reading some screen fields..  Include program is L0PXVF01….
    Now my question is do you guys have any good solution, it might possible I’m doing it using the short path .. ( Cuz I wna use my security program as its using feature ) 
    Let me know if u have some idea…
    Thanks
    Saquib Khan

    1- Well I’m thinking that I have to compare T558M on the base of Feature and variable key . And see that standard field is hidden... if it is .. I want to also HIDE my custom field ....
    2- For our feature "p0002" , we have developed a custom code in which on the basis of variable key and user profile it get executed and also see wther that person has authorization to see that standard field or not . if say that person doesn’t have authorization for that field I can also hide mine custom field. 
    I just got the test login and I’m going to test it by add/removing security roles .
    <b>
    I tried that out but if I’m looping at screen , its behaving same for both users . Cuz there is nothing which tells ok for this user fild is hidden in T558m and its open for other one..
    Also, is there any FM if I pass Dynpro # , molga and variable key , it return me T588M hidden fields ...
    I already tried the above FM
    This looks like to work but not working for field
    HR_T588M_GET_FIELDATTRIBUTES</b>
    Thanks for valuable input!!
    Saquib

  • Error while running fiori application in launchpad which is having image in its empty view

    Hi Experts,
                   I have created a fiori application using odata services and uploaded it into launchpad.I want to display image in its empty view. It is getting displayed when i run the application on eclipse but i am getting the error for the same when i run it on launchpad.
    Below is the error:
    "NetworkError: 404 NOT FOUND - http://ws-sapsvr01:8010/sap/bc/ui5_ui5/ui2/ushell/shells/abap/img/TeamSAP.jpg"
    Can any body help me solve this issue why i am getting this??
    Thanks & Regards.
    Rahul.

    Hi Masa,
    In my case, i've the file 'preco_ok.jpg' located inside my extended project (Z_MM_MyProject -> WebContent -> images)
    And I refer it as follow:
    <Image src="images/preco_ok.jpg" class="spaceIndicator"/>
    In the local enviroment it is ok, but on launchpad, the 404 error is shown:
    GET http://host:port/sap/bc/ui5_ui5/ui2/ushell/shells/abap/images/preco_ok.jpg 404 (NOT FOUND)
    Thank you for your support.

  • I am trying to use logic pro 9 on my lion system and it continues to say I have a bad midi...when i go to check my midi drivers folders in my library its empty...does anyone know whats going on?

    i am trying to use logic pro 9 on my lion system and it continues to say I have a bad midi...when i go to check my midi drivers folders in my library its empty...does anyone know whats going on?

    I
    got your message about making sure to use the machine specific disk that came with my machine. Unfortunately, Apple no longer sells Tiger replacement disks. I've got a couple of bids out on ebay, and will update when I have news to add to this post.
    Thank you for your help, Frank!
    To be clear you called the 800 number and explained what the situation was, old machine and lost the original DVD's?
    Just checking because if you just called and tried to buy the DVD's they might tell you they no longer sell them but you aren't really trying to buy them your trying to replace the ones that are missing.
    Ebay may work but there is a certain specificity to the DVD's required which, even if they seem right, might not work.
    Good luck either way. If you get a chance when you get the DVD's I'd be interested in hearing how it all works out.
    regards

  • I'm a new Mac user. I imported photos from my PC they ended up in iphoto library on the hard drive, but when I open iphoto from my dock its empty. How do I import those photos to the dock file?

    I'm a new Mac user. I imported photos from my PC through a jump drive and they ended up in my iphoto library on the hard drive but when I open iphoto from the dock its empty. How do I import those photos to the dock file from the iphoto library?

    Paragon Software has the most reliable NTFS driver for Mac
    tips on importing and organizing, transferring from Windows etc
    http://www.apple.com/support/itunes
    http://www.ilounge.com

  • How to hide fields in product master data

    Hi gurus,
    could you please tell if it's possible to hide fields in Product maintenance (tr. COMMPR01).
    It's necessary to hide some fields in a standard Set type.
    Thanks in advance, Sunny.

    Hi, TooCan and K.narsimha rao,
    I've tried to use transaction variant. It really helps.
    Thank you!
    It was better for me to find some customizing in SPRO but as I understand there is no such.
    Reward  you
    Best regards, Sunny.

  • How to hide fields in UIX form

    Hi
    I need to update the table with last_updated_by and last_updated_date every time if any change to the record. But I do not want to show these 2 fields on the screen.
    Could you help me how to hide fields in UIX form/any procedure to insert the data to database with out placing them in the screen .
    Thanks in advance.
    NRK

    Now that you mention it ... the rendered flag will stop the field from being rendered. So it's not even in the page. Stupid me.
    Have a look at formValue. These are rendered, but invisible fields in a form. That should do it (hopefully).
    In prepareForDML() you could simply call the setter of your date attribute that stores the date of the last update. There you pass the current date, or you could fetch the sysdate from the database and pass that. If you go that way, then the EntityImpl could make these adjustments automatically when inserting or updating and you wouldn't even need these fields/bindings in your UIX page.
    Just check what the operation is, and if it's an update or insert then call the setters of the attributes you want to update. Then call super.prepareForDML(). Something like that.
    It all would happen in the middle-tier, client not involved.
    So formValue should work, and the prepareForDML() stuff should also work. Don't know which way you want to go.
    Sascha

  • How to hide field dynamically in a report while using JRC

    Post Author: prateeti
    CA Forum: JAVA
    How can I hide fields in a report dynamically?Say my report now contains 3 fields(columns). Some users want to see the 1st and 3rd column and the 3rd column must be adjusted accordingly so that it appears where the2nd column previously was.Is there any way of doing such thing using API's from JRC.I am not using RAS.
    Thanks.

    Post Author: something_stupid
    CA Forum: JAVA
    Hi,
    you could to this while designing your report in CrystalReports. Pass the user's choice as parameters to your report on runtime. This parameter is evaluated and changes visibility and position of columns conditionally. Actually haven't done this with visibilty and position but with strings to display conditionally.
    good luck!

  • How to remove target node if source field value is empty SAP PI Mapping

    Hello,
    how to remove target node if source field value is empty in graphical Mapping.
    Like if
    MIddle name in source filed is empty, I would like to eliminate target field from out put XML.
    Thank you
    John

    Hi Jhon,
    If you want to remove all empty tags and you dont to complicate your message mapping, you can use a XSL, after the message mapping,  to remove all the empty tags:
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:template match="node()|@*">
            <xsl:copy>
                <xsl:apply-templates select="node()|@*"/>
            </xsl:copy>
        </xsl:template>
        <xsl:template match="*[not(@*|*|comment()|processing-instruction())
         and normalize-space()='' ]"/>
    </xsl:stylesheet>
    Regards

Maybe you are looking for