Show/ Hide region based on button click

Hi,
I have two report regions. When I press generate report button then, one region has to be displayed.
I have an item "select list with submit " and if select some value from the LOV in the select list then the second region has to be displayed. Over all only one region has to be displayed at a time.
Thanks in advance.

See this thread for a possible answer: Hide/Show Region With Javascript
Thank you,
Tony Miller
Webster, TX

Similar Messages

  • Hide/Show a graph based on button click .

    I have to show a graph based on the values selected in the shuttle . The graph should be drawn only when a button( "Show graph") is clicked . My question is
    1) If the set the button's action to submit, it resets and empties the selected values in the shuttle . How do I prevent that ?
    2) How do I make the graph appear and disappear based on the button click ( Like a toggle button ) ?
    3) As I can draw the graph only from the values selected in the shuttle , the query parsing fails . However , the graph displays when the shuttle get populated with selected values . Is there a way to get around that .
    Thanks for your help .

    There is nothing wrong with your code, so I'd look elsewhere for the problem. Is this a direct copy of what you have on your page?
    :P1_COMBO1 in ('Option 1', 'Option 2')
    And
    :P1_COMBO2 = 'Option Combo 2'And the page item values are exactly as you have in the quoted strings? You might run the page in debug and confirm the page item values are exact.
    Edited by: Bob37 on Dec 6, 2011 2:18 PM

  • Show/Hide Regions using list (Button List Template)

    Hi,
    I have a page on which i'm using list (Button list - Template). Below lists, I have multiple form regions. When a user opens that page, all regions should be visible and the focus should be on 'Show All' list. However, Region 'Terms' should only be visible when list 'Terms' is selected. The same functionality should apply to other regions and lists. I have seen that Oracle has used a similar functionality when an Item on a page is clicked or opened.
    Does anybody know how to do it?

    I'm trying to use the hide/show region in the posting to hide a button region when I click the button.
    When I click my button it calls SubmitCmd(sCmd) and hits the alert popup "Here we go!" but then all the AJAX inserts happen and THEN the region hides.
    I guess the alert is Async and the $x_Hide(l_Item); is not or something like that??
    How can I hide the region and then process the rest with the same button click?
    Or how can I hide just a normal button when I click it.. same thing though, need to do it before processing of AJAX inserts.
    function SubmitCmd(sCmd){
    var lQuesID;
    var elmName;
    var elm;
    lcontinue = true;
    showMessage('');
    alert('Here we go!');
    $x_Hide(l_Item);
    var lAdtUseID =html_GetElement('P3_AUDIT_USE_ID').value;
    etc.. a bunch of AJAX inserts, etc..

  • Dynamic action - show/hide region based on LOV which returns ID

    Hi folks,
    this should be simple, so someone who works with dynamic actions.
    I have a LOV which is based on below query:
    select OBJECT_ID, KOD
      from x_data x;
    retuns:
       ID          KOD
        492961 BMW
        492964 VOLVO
        492960 MERCEDES
        492963 VOLKSWAGEN
        492959 SKODAItem :P200_KOD is based on LOV which displays KOD and returns ID.
    On my page I have also 1 region called TEST_REGION.
    I would like to set up a dynamic action shich will SHOW/HIDE a TEST_REGION based on selected value in item :P200_KOD (LOV). Region should be showed if displayed (KOD) value of selected ID starts with 'V%'
    By other words, if below query returns any record, then SHOW, else HIDE:
       select *
        from x_data x
      where x.kod like 'V%'
         and x.object_id = :P200_KOD;How should I define a triggering condition for dynamic action, for item :P200_KOD?
    Thanks,
    Tomas

    Hi,
    One way:
    Create advanced dynamic action.
    Name : Hide region
    Event : Change
    Selection Type : Item(s)
    Items(s) : P200_KOD
    Condition : JavaScript Expression
    Value :
    $(this.triggeringElement).children("option:selected").html().substring(0,1) !== "V"Action : Hide
    Fire On Page Load : True
    Hide all page items on the same line : No
    False Action : Show
    Fire On Page Load : True
    Show all page items on the same line : No
    Selection Type : Region
    Region : TEST_REGION
    Regards,
    Jari
    http://dbswh.webhop.net/dbswh/f?p=BLOG:HOME:0

  • Javascript Help Needed to Show/Hide Regions

    version 4.0.2.00.07
    Hello,
    I'm hoping that someone would help me with creating a Javascript function to Show/Hide regions.
    I have a Select List defined as Checkboxes that when clicked I would like to show specific regions that contain fields that are specific to that checkbox selection. There are currently four selections available. There are two selections that would show one region and the other two selections would show the other region.
    Please let me know if I need to clarify anything.
    Thanks,
    Joe

    There is an out-of-box solution that may help you - check out the "Customisation" section in the region properties.
    Otherwise, you might like to explore using a Dynamic Action to show/hide your region based on an event on your relevant checkbox.
    Either way, you should have a declarative solution when you thought you might need to hand-code some javaScript :-)
    ps - thanks for providing your Apex version.

  • Robo v9 Show/Hide without Twisties - One button no longer working

    Hey there, as stated I am using Robo v9 with Show/Hide without Twisties (One button) with javascipts.  We have most of our images using DHTML drop-downs and when folks click on "Show All Images" on the page, the GIF changes to "Hide All Images" and all drop-downs (our images) and expanding text are diaplayed.
    It had been working all the time, but now it only works when I right click the topic in the TOC and choose "Edit Topic", then while in the Edit Window (Display view), when I do a View (Ctrl-W) and it displays the page within RoboHelp..I can click the "Show All Images" and it works like it always had.  BUT, if that page is not in the Edit Window, and I right click "Preview Topic", the click "Show All Images" (or on the DHTML dropdown itself) it will NOT show the images, *but the GIF image does properly toggle to "Hide All Images" (and if I do again, then it properly toggles to the "Show All Images" GIF, if I do it again), but now NO images are getting displayed for some reason.  It also NEVER works properly when I publish to our website (even when clicking the DHTML dropdown itself), but the GIF images toggle properly.
    If I right click and choose "Preview Topic" and click "View With" and use Internet Explorer 8 it still never works anymore, unless the topic is in the Edit Window (Display View), so I know the issue is not on the server.  It stops working after I do a generate and run on my pc.  Also when I view it IE8 within Robo (and Allow the Blocked Content to run the scripts), many instances of the same error is shown as:
    Message: Access is denied. 
    Line: 2646
    Char: 3
    Code: 0
    URI: file:///D:/Users/_RBH9_TPO-Generate/v9-testing/ehlpdhtm.js
    ...but I *do* have access to the folder system, but in checking the coding of the ehlpdhtm.js, that area show, where I believe line 2646, character 3 starts at the "values = getAttribute(element, prop );" line below...but maybe something does not exist:
    ==
      //End HTML code invoked function
    function InitEffect( element, prop )
    var values = null;
    if( getAttribute(element,prop)) 
      values = getAttribute(element, prop );
    else if( getAttribute( element, "currentStyle" )  && element.currentStyle.getAttribute)
      values = element.currentStyle.getAttribute( prop );
    else  if (element.style.getAttribute)
      values = element.style.getAttribute( prop );
    if( !values )
      return;
    var functions = new Array();
    ==
    I have a much older backup when restored, it all works properly again in all cases, but I have done so much work since then that I think would need to be manually redone.  I have played with keeping those some javascipts alone (in case I changed something) and updated the rest of the data files I had added, deleted the .CPD file, but it somehow stops working again, probably with some updated file.  I am not sure what specific files could be causing the negative impact that is preventing it from working.  Maybe if I knew what files could impact, I couldrestore those from my old backup.  The newer backups when restored do not work properly, so there was a point in time where something changed and is causing this.
    All prior versions of RoboHelp (v7 and v8) have always worked and still do.  I am using v9.0.1.262, as the latest version has not yet been allowed on our pcs (per security), but since my earlier backup works, I thought it may not be the issue, but wanted to tell you anyway.  ;->
    Any ideas on how I should proceed?  What files may have impact to cause it not to work anymore?  The showhide.js is the only .js to show up as a baggage file.  Also, the DHTML line does exits in each html page's code, as we are still using Robo v7 as the production software and the Show/Hide always works, and I copy them into the respective Robo v9 folders (and if new, then I copy them, then import them), otherwise the newer v7 updated pages are copied over the older v9 html files while RoboHelp is closed.
    Thanks in advance for any info you can provide!

    I may have figured out what to fix to get v9 back to working on the Show/Hide button, but not the "why?" .
    It looks to all be dealing with the Robo automatic html coding of where to locate the .js file(s)...here is a quick overview of this issue and what I did.  When I view the non-working pages within Internet Explorer 8 within Robo (and Allow the Blocked Content to run the scripts), I saw many instances of the same error is shown as this in the log, which implied since I *do* have access rights, maybe the file was just not being found.
    Message: Access is denied.
    Line: 2646
    Char: 3
    Code: 0
    URI: file:///D:/Users/_RBH9_TPO-Generate/v9-testing/ehlpdhtm.js
    OK, here are my findings.  EXAMPLE #1 and EXAMPLE #2 below are excerpts of the same file.  EXAMPLE #1 is from Robo v7 and is copied to the v9 folder after it was updated so our soon to be "production" webhelp will be from Robo v9 (instead of making the same manual updates in Robo v9 as in Robo v7, I copy the updated the .html file to the Robo v9 file system).  Note the direction of the directory slashes of the java scripts listed below, as they are all DOS type slashes (back slashes), EXCEPT for ehlpdhtm.js as it is the ONLY one using UNIX (forward) slashes.
    EXAMPLE #1 (from Robo v7)
    ==
    <link rel="StyleSheet" href="..\..\sty-std-topic.css">
    <script type="text/javascript" language=JavaScript x-save-method=compute-relative
    src="..\..\showhide.js"></script>
    </head>
    <body>
    <robohelp><script type="text/javascript" language=JavaScript1.2 src="../../ehlpdhtm.js"
    x-save-method=compute-relative></script>
    <script type="text/javascript" language=JavaScript1.2>
    <!--
    if( typeof( InitEffects ) != 'function' ) InitEffects = new Function();if( typeof( InitTrigger ) != 'function' ) InitTrigger = new Function();if( typeof( FilePopupInit ) != 'function' ) FilePopupInit = new Function();if( typeof( TextPopupInit ) != 'function' ) TextPopupInit = new Function();
    //-->
    </script>
    ==
    EXAMPLE #2(from Robo v9)
    This is from the restored backup of the Robo v9 files that always work when I restore them, and note they are ALL UNIX (forward) slashes.  These backup files were generated from Importing/Upgrading a copy of the Robo v7 files into Robo v9.
    ++
    <title>[Endpoint Protection] Symantec Overview</title>
    <link rel="StyleSheet" href="../../sty-std-topic.css" type="text/css" />
    <script type="text/javascript" language="JavaScript" src="../../showhide.js">
    </script>
    </head>
    <body>
    <?rh-script_start ?><script src="../../ehlpdhtm.js" type="text/javascript" language="JavaScript1.2">
    </script><?rh-script_end ?>
    ++
    Additional info: The following is from another file from the Robo v9 backup files that always WORK and once again they are ALL UNIX (forward) slashes. 
    ~~
    <link rel="StyleSheet" href="../../sty-std-topic.css" type="text/css" />
    <script type="text/javascript" language="JavaScript" src="../../showhide.js">
    </script>
    </head>
    <body>
    <?rh-script_start ?><script src="../../ehlpdhtm.js" type="text/javascript" language="JavaScript1.2">
    </script><?rh-script_end ?>
    ~~
    BUT since all .js files are referenced in EXAMPLE #1 have DOS slashes (back slashes), EXCEPT for the ehlpdhtm.js, I decided to change the line in ehlpdhtm.js FROM src="../../ehlpdhtm.js" TO src="..\..\ehlpdhtm.js" and IT (this one page) BEGAN WORKING AGAIN after I published.  So having all DOS back slashes DOES work in Robo v9!!!!  BUT it appears that Robo v9 only generates new pages using UNIX (forward) slashes in ALL coding.  I've read about issues like this occurring with the FireFox browser, but we only use IE8, and have not read anything like this related to IE8 issues. 
    So if all UNIX forward slashes and all DOS back slashes can work in Robo v9 in finding and using ehlpdhtm.js, (the Show/Hide buttons function properly) why is this problem existing in Robo v9 when there are mixed "slashes" (using forward and backward)?  ...and the mixed slashes ALWAYS works in Robo v7!  They do not have to all be in the same direction in Robo v7 as it appears to have to be in the newer/more advanced Robo v9.  Why does it matter that all slashes need to be all the same direction, if Robo v9 CAN actually read and figure out the DOS back slashes (formatted by Robo v7 creation) and actually generates UNIX forward slashes for the .js files in new Robo v9 output within the .html?
    More importantly will I have to always do a Global search and replace in Robo v9 to change the direction of the "back slashes" when I copy updated Robo v7 .html files into the Robo v9 folders (instead of manually reworking each change), while in transition from v7 to v9?
    Thanks in advance any information, recommendations, and feedback as your time is greatly appreciated!

  • Dynamically show/hide regions out of the application workflow

    hi,
    is it possible to show/hide regions of a page dynamically with a "select list with submit" item?
    regards

    Hi,
    Do you mean "Conditionally display" items based on the value of a Select List with Submit?
    Andy

  • Single form Multiple Actions based on button click

    Hi,
    I have to call two different actions based on button click from single <form > .
    How to achive this?.
    Thank you

    Hi,
    I am using struts <html:form> and my code is as follows
    <script language="javascript">
              function setAction(val){
         if(val==A){
                   window.open(document.forms[0].action="preview.do");
         }else if(val==B){
         document.forms[0].action="create.do";
              document.getElementById('fcreate').submit();
    </script>
    <html:form action="/create.do" >
    <html:text property="name">
    </html:form>
    action is mandatory for <html:form>
    Its not sending the form elements, when I click the preview button.
    Create button works fine. In struts-conig, I have taken same form name for create and preview actions
    Please give me some tips
    Thank you

  • Show/Hide Fields Based on Dropdown

    Hi,
    I am attempting to show/hide subforms with a dropdown selection. I've found a lot of information on the subject, and have ended up with this as my script:
    form1.Page1.Division::exit - (JavaScript, client)
    switch (Page1.Division.rawValue)
       case "1":
       SubformZZI.presence = "visible";
       SubformZZR.presence = "hidden";  
          break;
       case "2":
       SubformZZI.presence = "hidden";
       SubformZZR.presence = "visible";      
          break;
    However, it is not doing anything when a selection is made in the dropdown box. I have the "SubformZZI" initially set as "Visible" and the "SubformZZR" initially set as "Hidden".
    Any suggestions?
    Regards,
    ZeroZone

    You have wrongly referenced the fields in your code.
    Copy and paste the below code in the click event of the Submit button. It should work as expected.
    The code thathas error is commented..
    // First check if there are null values, then construct email using script
    var vEmail = "";
    var vSubject = "";
    var vBody = "Attached to this email is a Field Service Issue - Parts Order Form for Job #" + Page1.JobNumber.rawValue + ".";
    var vName = "";
    var vCC =  "[email protected]" + "," + Page1.RSM.rawValue + "," + Page1.IssueLeaderEmail.rawValue; 
    var vFormat = "PDF";
    var errorMessage = "At least one required field was empty. Please fill in the required fields (highlighted) before continuing.";
    // Check required fields and build error message
    if (Page1.IssueLeaderEmail.rawValue == null)
    errorMessage = errorMessage;
    else
    vSubject = "Field Service Issue - Parts Order Form for Job #" + Page1.JobNumber.rawValue;
    // Check Division field
    if (Page1.Division.rawValue == "Case Division")
         //vEmail = Page1.SendFormToZZI.rawValue;
         vEmail = Page1.SubformZZI.SendFormToZZI.rawValue;
         //vCC = Page1.SendCopyToZZI.rawValue + "," + Page1.CSTZZI.rawValue;
         vCC = Page1.SubformZZI.SendCopyToZZI.rawValue + "," + Page1.SubformZZI.CSTZZI.rawValue;
    else
         //vEmail = Page1.SendFormToZZR.rawValue;
         vEmail = Page1.SubformZZR.SendFormToZZR.rawValue;
         //vCC = Page1.SendCopyToZZR.rawValue + "," + Page1.CSTZZR.rawValue;
         vCC = Page1.SubformZZR.SendCopyToZZR.rawValue + "," + Page1.SubformZZR.CSTZZR.rawValue;
    // If fields required for script are null, warn user and do not initiate email
    if (Page1.IssueLeaderEmail.rawValue == null)
    xfa.host.messageBox(errorMessage, "Sending an email", 0, 0); // Send out a custom error message if any of these fields are null
    else
    // Everything is OK, send email
    event.target.submitForm({cURL:"mailto: "+ vEmail +"?subject=" + vSubject +"&body=" + vBody + "&cc=" + vCC,cSubmitAs:"PDF",cCharset:"utf-8"});
    Thanks
    Srini

  • Show / hide field based on text in another field

    Hi,
    I'm trying to make one of my fields reactive to what is the text generated in another field.
    At the moment I have this under calculate using custom javascript:
    var Mask = this.getField("Course").value;
    if(Mask == 'Swimming') this.getField("Code").display = display.visible;
    else this.getField("Code").display = display.hidden;
    Whereas Course is the field that is changing and Code is the one that will show/hide based on content of Course.
    Any help?

    Hi Everyone,
    After doing trials with simple calculations it still wasn't working and so I've figured out what the problem is - the document was being exported but with the data being pre-populated from an SQL database in which during the export it all happens at once, not a chain effect so when the export happens it was filling "Code" before "Course" had any info in it...
    The fix was basically having to create a different field in the SQL source itself for an independent field on the pdf form.

  • Show a custom component on button click in a view stack`

    Hello folks
    I have a view stack in which i have some custom components.
    Now there is one custom component in which there is one button. On the button click, i want to show another custom component but i dont know how to do it. Should i write the inline mxml click event in custom component?? If yes then how??
    Currently i am doing it as
    click="{customcomponent}"

    As you know, ViewStack  has containers, lilke VBox for its views.
    Assuming one of your views VBox has an id of myVBox, and that VBox has the Button that when clicked will display the component, just have the component in the view already, but you can make it invisible with visible=false and includeInLayout=false, and then upon button click set those two variables to true.
    You will probably want a show handler for the view VBox to make those properties false each time that view is displayed.
    Here is some simple sample code.
    If this post answers your question or helps, please mark it as such.
    ---------- MySimpleComponent.mxml ----------
    <?xml version="1.0" encoding="utf-8"?>
    <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"
      width="100%" height="100%" horizontalAlign="center">
      <mx:Label text="My Custom Component"/>
    </mx:VBox>
    ---------- MainApp.mxml  ----------
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
      xmlns:comp="*" horizontalAlign="center" verticalAlign="middle">
      <mx:Script>
        <![CDATA[
        ]]>
      </mx:Script>
      <mx:LinkBar dataProvider="{vs}"/>
      <mx:ViewStack id="vs" width="100%" height="100%">
        <mx:VBox label="view1" width="100%" height="100%"
          horizontalAlign="center">
          <mx:Label text="View One"/>
        </mx:VBox>
        <mx:VBox label="view2"  width="100%" height="100%"
          show="myComp.visible=false;myComp.includeInLayout=true;"
          horizontalAlign="center">
          <mx:Label text="View Two"/>
          <mx:Button label="Make myComp Visible" click="myComp.visible=true;myComp.includeInLayout=true;"/>
          <comp:MySimpleComponent id="myComp" visible="false" includeInLayout="false"/>
        </mx:VBox>
      </mx:ViewStack>
    </mx:Application>

  • How to show/hide total based on selected column in column selector

    Hello,
    Is there a way to show/hide the total based on what column is selected in the column selector? Or alternatively to hide the total based on the column selected? I'm using OBIEE 10g.
    Basically, I have a pivot table with a handful of row variables and one measure. Then I allow the user to select the column variable. The default is to have nothing, which I have achieved using the hidden/dummy column trick (Re: How to add new columns by using Multiselect However, if my pivot table is set to have a total, I now get 2 columns that are the same. When the user selects any other choice (e.g. gender), I would want to see Male, Female and the total. Something like this:
    Default:
    Count
    East 10
    West 20
    Total 30
    Gender:
    Male Female Total
    Count Count Count
    East 6 4 10
    West 14 6 20
    Total 20 10 30
    Any thoughts?
    Thanks!

    I recommend using view selector instead of column selector

  • APEX 4.1 show hide fields based on value of checkbox/radio

    I am trying to successfully hide and show fields based on the value of a clicked checkbox.  I am using a dynamic action, but it isn't working. 
    I followed the sample at Does Oracle Apex 4 enable the following AJAX features? (ie without the dev writing the Javascript) - Stack Overflow
    I even tried a radio button, but it didn't work.  I cannot uncheck the radio button.  What am I doing wrong?  Thank you for any help you can provide.

    Hi,
         create a dynamic action for page load to hide the item which you wanna hide
         now create another dynamic action
         event : Click
         Selection Type : Items
         Items : P1_Check_box(name of the check box item)
         condition : equal to
         value : return value of the check box item (if you click the check box and the return value is 1 then just add 1)
         in true actions
         Action : Show
        Selection Type : Items
         Items : P1_Text_field(name of the field)
         uncheck fire on page load
         create exact opposite false action, that's it.
    Regards,
    Mohan.

  • Simple "show / hide" script using radio buttons, need a little help

    Hello;
    I have a place in my form where I need to swap out what type of form you need to fill out in an area. If I don't do this, it makes the page look over crowded and if I pass it off to a 2 or 3 step process, it doesn't have enough info in each section to be worth it. It's either one or the other.
    Right now, this code works nice. click on a radio button, and the form section appears and disappears. What I am trying to make this do it when the page loads, one of the radio buttons is selected and one of the form sections is visible. Then if you click on the other radio button, it swaps them.
    can anyone help me tweek this code so one of the buttons is selected all the time?
    here is my script.
    <style type="text/css">
    .showHide {
    position: absolute;
    background-color: #f1f1f1;
    width: 350px;
    padding: 1px;
    color: black;
    border: #999999 2px dashed;
    display: none;
    </style>
    <script language="JavaScript">
    function setVisibility(id, visibility) {
    document.getElementById(id).style.display = visibility;
    </script>
    <form>
    <input name=type type=radio onclick="setVisibility('sub3', 'inline');setVisibility('sub4','none');" value='male' checked>Selection 1
    <input type=radio name=type value='female' onclick="setVisibility('sub3', 'none');setVisibility('sub4','inline');";>Selection 2
    <div id="sub3" class="showHide">Selection 1 content</div>
    <div id="sub4" class="showHide">Selection 2 content</div>
    </form>
    That's the short of it with out dumping tons of other code on anyone.
    Thank you

    That's what I need. I tweeked it a little and now it doesn't work. Can
    you help me add one last option? I need 3 buttons that intereact leaving the red one still visible when it loads unless you click on
    one of the others. this is what I'm trying to do:
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
    <script type="text/javascript">
    $(document).ready(function() {
    $('#divGrey').hide();
    $('#divRed').show();
    $('#divBlue').hide();
    $('.grey').click(function(){
    //$(this).hide();
    $('#divGrey').show();
    $('#divRed').hide();
    $('#divBlue').hide();
    $('.red').click(function(){
    //$(this).hide();
    $('#divGrey').hide();
    $('#divRed').show();
    $('#divBlue').hide();
    $('.blue').click(function(){
    //$(this).hide();
    $('#divGrey').hide();
    $('#divRed').hide();
    $('#divBlue').show();
    </script>
    <style type="text/css">
    #divGrey {
    position: absolute;
    background-color: #f1f1f1;
    width: 350px;
    padding: 1px;
    color: black;
    border: #999999 2px dashed;
    display: none;
    #divRed {
    position: absolute;
    background-color: #f1f1f1;
    width: 350px;
    padding: 1px;
    color: black;
    border: #999999 2px dashed;
    display: none;
    #divBlue {
    position: absolute;
    background-color: #f1f1f1;
    width: 350px;
    padding: 1px;
    color: black;
    border: #999999 2px dashed;
    display: none;
    </style>
    <input type="radio" name="Radio1"  value="" id="RadioGroup1_1" checked="checked"  />Selection 1
    <input type="radio" name="Radio1"  value="checked" id="RadioGroup1_0" />Selection 2
    <input type="radio" name="Radio1"  value="checked" id="RadioGroup1_2" />Selection 3
    <div id="divRed">Selection 1 content</div>
    <div id="divGrey">Selection 2 content</div>
    <div id="divBlue">Selection 3 content</div>
    it isn't doing anything right now, and no errors either that I can see. Any ideas?

  • How to show/hide div based on mysql value

    I have a dataset that has a column 'locked' that is a boolean that I want to use to remove a button on a form.  The idea being that it will be set to 1 after a period of time thus removing the buttun that links to an update form and preventing the data from being changed.  Currently, I have the field linked to a check box at the top of the table.  How do I use this to hide the button (or any other html element for that matter) when set to 1 and show the element when set to 0?  I understand I need to creat a php variable from the mysql boolean and then use a if/else loop to hide/display the html but I don't know how to impliment this?  Thanks for any help offered.
    Here's the code:
    <?php require_once('Connections/testmypms.php'); ?>
    <?php
    $currentPage = $_SERVER["PHP_SELF"];
    $maxRows_spec_rx = 10;
    $pageNum_spec_rx = 0;
    if (isset($_GET['pageNum_spec_rx'])) {
      $pageNum_spec_rx = $_GET['pageNum_spec_rx'];
    $startRow_spec_rx = $pageNum_spec_rx * $maxRows_spec_rx;
    $colname_spec_rx = "1";
    if (isset($_GET['pxID'])) {
      $colname_spec_rx = (get_magic_quotes_gpc()) ? $_GET['pxID'] : addslashes($_GET['pxID']);
    mysql_select_db($database_testmypms, $testmypms);
    $query_spec_rx = sprintf("SELECT spec_rx.spec_rx_id, spec_rx.FK_px_id, DATE_FORMAT(spec_rx.spec_rx_date, '%%d-%%m-%%Y') as formatted_rx_date, spec_rx.FK_user_id, spec_rx.spec_rx_rsph, spec_rx.spec_rx_rcyl, spec_rx.spec_rx_raxis, spec_rx.spec_rx_rhprism, spec_rx.spec_rx_rhprismbase, spec_rx.spec_rx_rvprism, spec_rx.spec_rx_rvprismbase, spec_rx.spec_rx_rnadd, spec_rx.spec_rx_rnhprism, spec_rx.spec_rx_rnhprismbase, spec_rx.spec_rx_rnvprism, spec_rx.spec_rx_rnvprismbase, spec_rx.spec_rx_rintadd, spec_rx.spec_rx_rinthprism, spec_rx.spec_rx_rinthprismbase, spec_rx.spec_rx_rintvprism, spec_rx.spec_rx_rintvprismbase, spec_rx.spec_rx_lsph, spec_rx.spec_rx_lcyl, spec_rx.spec_rx_laxis, spec_rx.spec_rx_lhprism, spec_rx.spec_rx_lhprismbase, spec_rx.spec_rx_lvprism, spec_rx.spec_rx_lvprismbase, spec_rx.spec_rx_lintadd, spec_rx.spec_rx_linthprism, spec_rx.spec_rx_linthprismbase, spec_rx.spec_rx_lintvprism, spec_rx.spec_rx_lintvprismbase, spec_rx.spec_rx_lnadd, spec_rx.spec_rx_lnhprism, spec_rx.spec_rx_lnhprismbase, spec_rx.spec_rx_lnvprism, spec_rx.spec_rx_lnvprismbase, spec_rx.locked, users.user_id, users.user_firstname, users.user_surname FROM spec_rx, users WHERE %s = spec_rx.FK_px_id AND spec_rx.FK_user_id = users.user_id ORDER BY spec_rx.spec_rx_date DESC, spec_rx.spec_rx_id DESC", $colname_spec_rx);
    $query_limit_spec_rx = sprintf("%s LIMIT %d, %d", $query_spec_rx, $startRow_spec_rx, $maxRows_spec_rx);
    $spec_rx = mysql_query($query_limit_spec_rx, $testmypms) or die(mysql_error());
    $row_spec_rx = mysql_fetch_assoc($spec_rx);
    if (isset($_GET['totalRows_spec_rx'])) {
      $totalRows_spec_rx = $_GET['totalRows_spec_rx'];
    } else {
      $all_spec_rx = mysql_query($query_spec_rx);
      $totalRows_spec_rx = mysql_num_rows($all_spec_rx);
    $totalPages_spec_rx = ceil($totalRows_spec_rx/$maxRows_spec_rx)-1;
    $colname_demographics = "1";
    if (isset($_GET['pxID'])) {
      $colname_demographics = (get_magic_quotes_gpc()) ? $_GET['pxID'] : addslashes($_GET['pxID']);
    mysql_select_db($database_testmypms, $testmypms);
    $query_demographics = sprintf("SELECT demographics.px_id, demographics.FK_title_id, demographics.firstname, demographics.surname, DATE_FORMAT(demographics.dob, '%%d-%%m-%%Y') as formatted_dob, title.title_id, title.title FROM demographics, title WHERE %s = demographics.px_id AND demographics.FK_title_id = title.title_id", $colname_demographics);
    $demographics = mysql_query($query_demographics, $testmypms) or die(mysql_error());
    $row_demographics = mysql_fetch_assoc($demographics);
    $totalRows_demographics = mysql_num_rows($demographics);
    $queryString_spec_rx = "";
    if (!empty($_SERVER['QUERY_STRING'])) {
      $params = explode("&", $_SERVER['QUERY_STRING']);
      $newParams = array();
      foreach ($params as $param) {
        if (stristr($param, "pageNum_spec_rx") == false &&
            stristr($param, "totalRows_spec_rx") == false) {
          array_push($newParams, $param);
      if (count($newParams) != 0) {
        $queryString_spec_rx = "&" . htmlentities(implode("&", $newParams));
    $queryString_spec_rx = sprintf("&totalRows_spec_rx=%d%s", $totalRows_spec_rx, $queryString_spec_rx);
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Spec Rx3</title>
    <script language="JavaScript" type="text/JavaScript">
    <!--
    function MM_goToURL() { //v3.0
      var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
      for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
    //-->
    </script>
    </head>
    <body>
    <p>Spec Rx</p>
    <p><?php echo $row_demographics['px_id']; ?></p>
    <p><?php echo $row_demographics['title']; ?> <?php echo $row_demographics['firstname']; ?> <?php echo $row_demographics['surname']; ?> <?php echo $row_demographics['formatted_dob']; ?> </p>
    <p>
      <input name="Add_spec_rx" type="button" id="Add_spec_rx" onClick="MM_goToURL('parent','add_spec_rx.php');return document.MM_returnValue" value="New Rx">
    </p>
    <p> <a href="<?php printf("%s?pageNum_spec_rx=%d%s", $currentPage, max(0, $pageNum_spec_rx - 1), $queryString_spec_rx); ?>">Previous</a> <a href="<?php printf("%s?pageNum_spec_rx=%d%s", $currentPage, min($totalPages_spec_rx, $pageNum_spec_rx + 1), $queryString_spec_rx); ?>">Next</a></p>
    <?php do { ?>
    <table border="1" cellspacing="1" cellpadding="5">
      <tr>
        <td> </td>
        <td><?php echo $row_spec_rx['formatted_rx_date']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_id']; ?></td>
        <td>locked:
        <input <?php if (!(strcmp($row_spec_rx['locked'],1))) {echo "checked";} ?> name="locked" type="checkbox" id="locked" value="1"></td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
      </tr>
      <tr>
        <td> </td>
        <td>Sph</td>
        <td>Cyl</td>
        <td>Axis</td>
        <td>HPrism</td>
        <td>HPrismBase</td>
        <td>VPrism</td>
        <td>VPrismBase</td>
        <td>NrAdd</td>
        <td>NrHPrism </td>
        <td>NrHPrismBase</td>
        <td>NrVPrism</td>
        <td>NrVPrismBase</td>
        <td>IntAdd</td>
        <td>IntHPrism</td>
        <td>IntHPrismBase</td>
        <td>IntVPrism</td>
        <td>IntVPrismBase</td>
      </tr>
      <tr>
        <td>R</td>
        <td><?php echo ($row_spec_rx['spec_rx_rsph']<>null) ? sprintf ("%+4.2f",$row_spec_rx['spec_rx_rsph']) : null; ?></td>
        <td><?php echo ($row_spec_rx['spec_rx_rcyl']<>null) ? sprintf ("%+4.2f",$row_spec_rx['spec_rx_rcyl']) : null; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_raxis']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_rhprism']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_rhprismbase']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_rvprism']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_rvprismbase']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_rnadd']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_rnhprism']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_rnhprismbase']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_rnvprism']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_rnvprismbase']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_rintadd']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_rinthprism']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_rinthprismbase']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_rintvprism']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_rintvprismbase']; ?></td>
      </tr>
      <tr>
        <td>L</td>
        <td><?php echo ($row_spec_rx['spec_rx_lsph']<>null) ? sprintf ("%+4.2f",$row_spec_rx['spec_rx_lsph']) : null; ?></td>
        <td><?php echo ($row_spec_rx['spec_rx_lcyl']<>null) ? sprintf ("%+4.2f",$row_spec_rx['spec_rx_lcyl']) : null; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_laxis']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_lhprism']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_lhprismbase']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_lvprism']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_lvprismbase']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_lnadd']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_lnhprism']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_lnhprismbase']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_lnvprism']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_lnvprismbase']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_lintadd']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_linthprism']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_linthprismbase']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_lintvprism']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_lintvprismbase']; ?></td>
      </tr>
      <tr>
        <td> </td>
        <td>User ID <?php echo $row_spec_rx['user_id']; ?></td>
        <td><?php echo $row_spec_rx['user_firstname']; ?></td>
        <td><?php echo $row_spec_rx['user_surname']; ?></td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
      </tr>
    </table>
    <p> </p>
    <?php } while ($row_spec_rx = mysql_fetch_assoc($spec_rx)); ?>
    <p> </p>
    <p> </p>
    <p> </p>
    </body>
    </html>
    <?php
    mysql_free_result($spec_rx);
    mysql_free_result($demographics);
    ?>

    Thanks for your help, nearly worked but only returned results where the if statement was met ie where locked =0, so I used an additional statement to display something else when when locked=1
    <?php
    if($row_spec_rx['locked'] == 1) {
    echo "button html goes here";
    ?>
    <?php
    if($row_spec_rx['locked'] == 0) {
    echo "something else";
    ?>
    I am sure there must be a more elegant way of doing this!

Maybe you are looking for