Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder MrBiggZ's Avatar
    Join Date
    Apr 2005
    Location
    Indianapolis IN
    Posts
    345
    Thanks
    44
    Thanked 2 Times in 2 Posts

    I would like to show a DIV pending a form submit, don't know how

    Hi!

    I know zero javascript and I've done a bit of Googling on the subject but only find where you can show/hide a DIV depending on a form input. I'm trying to show a DIV pending a value from a form submit.

    My main language is PHP and upon submitting this form I have the following values. Only way I can set the display to hidden for an element in PHP is at the load time. There is no way that I know of to make it happen dynamically when a forms value changes.

    Array
    (
    [team] => 3||Rumble
    [ftype] => change
    [maint] => Submit
    [submit_check2] => 1
    )
    I would want to base the showing the DIV on the ftype variable which can be either 'change' or 'add.' And respectively I would have two DIV's with the id's of 'change-mgmt' and 'add-mgmt.'

    I'm just lacking in the know how to write the code. =((

    Thanks for any help!
    “No matter how slick the demo is in rehearsal, when you do it in front of a live audience, the probability of a flawless presentation is inversely proportional to the number of people watching, raised to the power of the amount of money involved.” ~ Mark Gibbs

  • #2
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,460
    Thanks
    11
    Thanked 600 Times in 580 Posts
    echo the ftype into a <body> class and use CSS to hide/show the #ID in question based on the attrib value
    my site (updated 2014/10/20)
    BROWSER STATS [% share] (2014/9/03) IE7:0.1, IE8:4.3, IE11:9.2, IE9:2.7, IE10:2.6, FF:16.8, CH:47.5, SF:7.8, NON-MOUSE:37%

  • #3
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,694
    Thanks
    25
    Thanked 657 Times in 656 Posts
    @MrBiggZ,
    I think this is what you want. the JS is in red. Didn't put it in form tags, not sure if this is really needed.
    Two ways
    Code:
    <!DOCTYPE html>
    <html>
    <head>
    <style type="text/css">
    #change-mgmt{
    	display:none;
    }
    #add-mgmt{
    	display:none;
    }
    </style>
    </head>
    <body>
    <input type="checkbox" name="change" id="change" onchange="document.getElementById('change-mgmt').style.display='block';document.getElementById('help').disabled = true;" >Change<br>
    <input type="checkbox" name="help" id="help" onchange="document.getElementById('add-mgmt').style.display='block';document.getElementById('change').disabled = true;" >Add help
    <br /><br />
    
    <div id="change-mgmt">Let's get rid of this guy!</div>
    <div id="add-mgmt">This guy needs help</div>
    </body>
    </html>
    AND:
    Code:
    <!DOCTYPE html>
    <html>
    <head>
    <style type="text/css">
    #change-mgmt{
    	display:none;
    }
    #add-mgmt{
    	display:none;
    }
    </style>
    </head>
    <body>
    <input type="text" name="change" id="change" onblur="document.getElementById('change-mgmt').style.display='block';document.getElementById('help').disabled = true;" >Change<br>
    <input type="text" name="help" id="help" onblur="document.getElementById('add-mgmt').style.display='block';document.getElementById('change').disabled = true;" >Add help
    <br /><br />
    
    <div id="change-mgmt">Let's get rid of this guy!</div>
    <div id="add-mgmt">This guy needs help</div>
    </body>
    </html>
    Evolution - The non-random survival of random variants.

    "If you leave hydrogen alone, for long enough, it begins to think about itself."

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,613
    Thanks
    80
    Thanked 4,634 Times in 4,596 Posts
    Quote Originally Posted by sunfighter View Post
    "If you leave hydrogen alone, for long enough, it begins to think about itself."
    Ummm...I think it takes hydrogen, oxygen, and carbon. But dang, the principal idea is perfect. <grin/>
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •