Solved

javascript hide submit button on click and show loading image instead

Posted on 2004-10-26
5,042 Views
Last Modified: 2008-01-09
i'm tryin to get this code to work but i'm having no luck, i want it to hide the submit button on click and show this loading image, any help is appreciated, thanks

      <td colspan = "10"><input type = "button" style = "visibility:visible;" value = "Generate Report" onclick = "this.style.visibility:'hidden', loading.style.visibility:'visible'">
      <img src="../../images/img-loading.gif" alt="" border="0" name = "loading" style = "visibility:hidden;"></td>
0
Question by:LTY83
    8 Comments
     
    LVL 13

    Accepted Solution

    by:

    <td colspan="10">
    <input
      type = "button"
      value = "Generate Report"
      onclick = "this.style.display = 'none'; loading.style.display = '';">

    <img
      src="../../images/img-loading.gif"
      alt=""
      border="0"
      name = "loading"
      id = "loading"
      style = "display: none;">
    </td>
    0
     
    LVL 13

    Expert Comment

    by:cLFlaVA
    OR

    <td colspan="10">
    <input
      type = "button"
      value = "Generate Report"
      onclick = "this.style.visibility = 'hidden'; loading.style.visibility = 'visible';">

    <img
      src="../../images/img-loading.gif"
      alt=""
      border="0"
      name = "loading"
      id = "loading"
      style = "visibility: hidden;">
    </td>
    0
     
    LVL 4

    Author Comment

    by:LTY83
    u solve my problems everytime, thanks man
    0
     
    LVL 31

    Expert Comment

    by:GwynforWeb
    <input type="button" style="visibility:visible;" value="Generate Report"
    onclick="this.style.visibility='hidden'; loading.style.visibility='visible'">
    <img src="http://www.experts-exchange.com/images/pe/1088274.jpg" alt border="0" name="loading"
    style="visibility:hidden;">
    0
     
    LVL 13

    Expert Comment

    by:cLFlaVA
    no prob :)
    0
     

    Expert Comment

    by:KMETAVZER
    Hi,
    i'm new here.
    I have this problem:
    Script working fine, but loading.gif into my module don't want rotate.
    (my loading.gif is an animated gif !)
    How i can solve this problem?
    Thanks for replies.


    <?php
    
    
    
    // no direct access
    
    defined('_JEXEC') or die('Restricted access');
    
    
    
    $label		= $params->get( 'label', '' );
    
    $buttontext		= $params->get( 'buttontext', '' );
    
    $resulttext		= $params->get( 'resulttext', '' );
    
    $checkall		= $params->get( 'checkall', '' );
    
    $pretext		= $params->get( 'pretext', '' );
    
    $forwardurl		= $params->get( 'forwardurl', '' );
    
    $s5_domain1		= $params->get( 's5_domain1', '' );
    
    $s5_break1		= $params->get( 's5_break1', '' );
    
    $s5_domain2		= $params->get( 's5_domain2', '' );
    
    $s5_break2		= $params->get( 's5_break2', '' );
    
    $s5_domain3		= $params->get( 's5_domain3', '' );
    
    $s5_break3		= $params->get( 's5_break3', '' );
    
    $s5_domain4		= $params->get( 's5_domain4', '' );
    
    $s5_break4		= $params->get( 's5_break4', '' );
    
    $s5_domain5		= $params->get( 's5_domain5', '' );
    
    $s5_break5		= $params->get( 's5_break5', '' );
    
    $s5_domain6		= $params->get( 's5_domain6', '' );
    
    $s5_break6		= $params->get( 's5_break6', '' );
    
    $s5_domain7		= $params->get( 's5_domain7', '' );
    
    $s5_break7		= $params->get( 's5_break7', '' );
    
    $s5_domain8		= $params->get( 's5_domain8', '' );
    
    $s5_break8		= $params->get( 's5_break8', '' );
    
    $s5_domain9		= $params->get( 's5_domain9', '' );
    
    $s5_break9		= $params->get( 's5_break9', '' );
    
    $s5_domain10	= $params->get( 's5_domain10', '' );
    
    $s5_break10		= $params->get( 's5_break10', '' );
    
    $s5_domain11	= $params->get( 's5_domain11', '' );
    
    $s5_break11		= $params->get( 's5_break11', '' );
    
    $s5_domain12	= $params->get( 's5_domain12', '' );
    
    $s5_break12		= $params->get( 's5_break12', '' );
    
    $s5_domain13	= $params->get( 's5_domain13', '' );
    
    $s5_break13		= $params->get( 's5_break13', '' );
    
    $s5_domain14	= $params->get( 's5_domain14', '' );
    
    $s5_break14		= $params->get( 's5_break14', '' );
    
    $s5_domain15	= $params->get( 's5_domain15', '' );
    
    $s5_break15		= $params->get( 's5_break15', '' );
    
    $s5_domain16	= $params->get( 's5_domain16', '' );
    
    $s5_domain17	= $params->get( 's5_domain17', '' );
    
    
    
    ?>
    
    
    
    <?php if ($pretext != "") { ?>
    
    <div style="margin-bottom:8px">
    
    <?php echo $pretext ?>
    
    </div>
    
    <?php } ?>
    
    
    
    <?php
    
    
    
        function checkDomain($domain,$server,$findText){
    
            // Open a socket connection to the whois server
    
            $con = fsockopen($server, 43);
    
            if (!$con) return false;
    
            
    
            // Send the requested doman name
    
            fputs($con, $domain."\r\n");
    
            
    
            // Read and store the server response
    
            $response = ' :';
    
            while(!feof($con)) {
    
                $response .= fgets($con,128); 
    
            }
    
            
    
            // Close the connection
    
            fclose($con);
    
            
    
            // Check the response stream whether the domain is available
    
    		// echo $response;
    
            if (strpos($response, $findText)){
    
    		
    
                return true;
    
            }
    
            else {
    
                return false;   
    
            }
    
        }
    
        
    
        function showDomainResult($domain,$server,$findText){
    
    	
    
           if (checkDomain($domain,$server,$findText)){
    
              echo "<div style='margin-bottom:4px;'><span style='color:black;'>$domain  </span><span style='color:green; font-weight:bold;'>Available</span></div>";
    
           }
    
           else echo "<div style='margin-bottom:4px;'><span style='color:black;'>$domain  </span><span style='color:red; font-weight:bold;'>Taken</span></div>";
    
        }
    
    	
    
    ?>
    
    
    
        <div style="width: 180px; background-color:transparent;">
    
          <form action="<?php echo $forwardurl ?>" method="post" name="domain" id="domain">
    
          <table border="0" align="center" style="background-color: transparent;">
    
          <tr>
    
          <td align="center" colspan="3">
    
    	  <span style="font-weight:bold">
    
            <?php echo $label ?> :
    
    	  </span>
    
    		<div style="margin-top:8px; margin-bottom:8px;">
    
    				<input class="text" name="domainname" type="text" />
    
    		</div>
    
    	  
    
    
    
    		<div style="margin-bottom:8px">	
    
                    <input type="checkbox" style="background-color:transparent;" name="all" checked="checked"/> <?php echo $checkall ?>
    
    		</div>
    
    	  </td>
    
    	  </tr>
    
          <tr>
    
          <td colspan="1" style="width: 58px; padding-left:16px;">
    
          <div>		
    
    		<?php if ($s5_domain1 == "yes") { ?>	
    
                    <input type="checkbox" style="background-color:transparent;" name="com"/> .com
    
    
    
    				<div style="height:8px;"></div>
    
    
    
    		<?php } ?>
    
    		
    
    		<?php if ($s5_domain2 == "yes") { ?>	
    
                    <input type="checkbox" style="background-color:transparent;" name="net"/> .net
    
    
    
    				<div style="height:8px;"></div>
    
    
    
    		<?php } ?>
    
    		
    
    		<?php if ($s5_domain3 == "yes") { ?>	
    
                    <input type="checkbox" style="background-color:transparent;" name="info"/> .info
    
    
    
    				<div style="height:8px;"></div>
    
    
    
    		<?php } ?>
    
    		
    
    		<?php if ($s5_domain4 == "yes") { ?>	
    
                    <input type="checkbox" style="background-color:transparent;" name="org"/> .org
    
    
    
    				<div style="height:8px;"></div>
    
    
    
    		<?php } ?>
    
    		
    
    		<?php if ($s5_domain5 == "yes") { ?>	
    
                    <input type="checkbox" style="background-color:transparent;" name="biz"/> .biz
    
    
    
    				<div style="height:8px;"></div>
    
    
    
    		<?php } ?>
    
    		
    
    		<?php if ($s5_domain16 == "yes") { ?>	
    
                    <input type="checkbox" style="background-color:transparent;" name="it"/> .it
    
    
    
    				<div style="height:8px;"></div>
    
    
    
    		<?php } ?>		
    
    	  </div>		
    
    	  </td>
    
          <td colspan="1" style="width: 62px; padding-left:4px;">
    
    	  <div>      		
    
    		<?php if ($s5_domain6 == "yes") { ?>	
    
                    <input type="checkbox" style="background-color:transparent;" name="couk"/> .co.uk
    
    
    
    				<div style="height:8px;"></div>
    
    
    
    		<?php } ?>
    
    		
    
    		<?php if ($s5_domain7 == "yes") { ?>	
    
                    <input type="checkbox" style="background-color:transparent;" name="name"/> .name
    
    
    
    				<div style="height:8px;"></div>
    
    
    
    		<?php } ?>
    
    
    
    		<?php if ($s5_domain13 == "yes") { ?>	
    
                    <input type="checkbox" style="background-color:transparent;" name="mobi"/> .mobi
    
    
    
    				<div style="height:8px;"></div>
    
    
    
    		<?php } ?>
    
    
    
    		<?php if ($s5_domain12 == "yes") { ?>	
    
                    <input type="checkbox" style="background-color:transparent;" name="edu"/> .edu
    
    
    
    				<div style="height:8px;"></div>
    
    
    
    		<?php } ?>		
    
    		
    
    		<?php if ($s5_domain10 == "yes") { ?>	
    
                    <input type="checkbox" style="background-color:transparent;" name="tv"/> .tv
    
    
    
    				<div style="height:8px;"></div>
    
    
    
    		<?php } ?>
    
    				
    
    	  </div>		
    
    	  </td>
    
          <td colspan="1" style="width: 58px; padding-left:2px;">		
    
    	  <div>		
    
    		<?php if ($s5_domain11 == "yes") { ?>	
    
                    <input type="checkbox" style="background-color:transparent;" name="eu"/> .eu
    
    
    
    				<div style="height:8px;"></div>
    
    
    
    		<?php } ?>
    
    		
    
    		<?php if ($s5_domain9 == "yes") { ?>	
    
                    <input type="checkbox" style="background-color:transparent;" name="us"/> .us
    
    
    
    				<div style="height:8px;"></div>
    
    
    
    		<?php } ?>
    
    		
    
    		<?php if ($s5_domain8 == "yes") { ?>	
    
                    <input type="checkbox" style="background-color:transparent;" name="cc"/> .cc
    
    
    
    				<div style="height:8px;"></div>
    
    
    
    		<?php } ?>
    
    		
    
    		<?php if ($s5_domain14 == "yes") { ?>	
    
                    <input type="checkbox" style="background-color:transparent;" name="nl"/> .nl
    
    
    
    				<div style="height:8px;"></div>
    
    
    
    		<?php } ?>
    
    		
    
    		<?php if ($s5_domain15 == "yes") { ?>	
    
                    <input type="checkbox" style="background-color:transparent;" name="ca"/> .ca
    
    
    
    				<div style="height:8px;"></div>
    
    
    
    		<?php } ?>
    
    		
    
    		<?php if ($s5_domain17 == "yes") { ?>	
    
                    <input type="checkbox" style="background-color:transparent;" name="si"/> .si
    
    
    
    				<div style="height:8px;"></div>
    
    
    
    		<?php } ?>		
    
    		</div>
    
    	    </td>
    
    		</tr>
    
    		<tr>
    
            <td colspan="3" align="center">				
    
    		    <div>
    
    				<input class="button" type="submit" onclick = "this.style.visibility = 'hidden'; loading.style.visibility = 'visible';" name="submitBtn" value="<?php echo $buttontext ?>"/>
    
    				<img src="/images/loading.gif" alt="" border="0" name = "loading" id = "loading" style = "visibility: hidden;" />
    
    			</div>	
    
    	    </td>
    
    		</tr>
    
    	    </table>
    
          </form>
    
    
    
    	  
    
    <?php    
    
        if (isset($_POST['submitBtn'])){
    
            $domainbase = (isset($_POST['domainname'])) ? $_POST['domainname'] : '';
    
            $d_all      = (isset($_POST['all'])) ? 'all' : '';   
    
    		
    
    		if ($s5_domain1 == "yes") {
    
            $d_com      = (isset($_POST['com'])) ? 'com' : ''; 
    
    		}	    
    
    		
    
    		if ($s5_domain2 == "yes") {
    
            $d_net      = (isset($_POST['net'])) ? 'net' : ''; 
    
    		}	
    
    		
    
    		if ($s5_domain3 == "yes") {
    
            $d_info      = (isset($_POST['info'])) ? 'info' : ''; 
    
    		}	   
    
    		
    
    		if ($s5_domain4 == "yes") {
    
            $d_org      = (isset($_POST['org'])) ? 'org' : ''; 
    
    		}	
    
    		
    
    		if ($s5_domain5 == "yes") {
    
            $d_biz      = (isset($_POST['biz'])) ? 'biz' : ''; 
    
    		}
    
    		
    
    		if ($s5_domain6 == "yes") {
    
            $d_couk      = (isset($_POST['couk'])) ? 'couk' : ''; 
    
    		}
    
    		
    
    		if ($s5_domain7 == "yes") {
    
            $d_name      = (isset($_POST['name'])) ? 'name' : ''; 
    
    		}
    
    		
    
    		if ($s5_domain8 == "yes") {
    
            $d_cc      = (isset($_POST['cc'])) ? 'cc' : ''; 
    
    		}
    
    		
    
    		if ($s5_domain9 == "yes") {
    
            $d_us      = (isset($_POST['us'])) ? 'us' : ''; 
    
    		}
    
    		
    
    		if ($s5_domain10 == "yes") {
    
            $d_tv      = (isset($_POST['tv'])) ? 'tv' : ''; 
    
    		}
    
    		
    
    		if ($s5_domain11 == "yes") {
    
            $d_eu      = (isset($_POST['eu'])) ? 'eu' : ''; 
    
    		}
    
    		
    
    		if ($s5_domain12 == "yes") {
    
            $d_edu      = (isset($_POST['edu'])) ? 'edu' : ''; 
    
    		}
    
    		
    
    		if ($s5_domain13 == "yes") {
    
            $d_mobi      = (isset($_POST['mobi'])) ? 'mobi' : ''; 
    
    		}
    
    		
    
    		if ($s5_domain14 == "yes") {
    
            $d_nl      = (isset($_POST['nl'])) ? 'nl' : ''; 
    
    		}
    
    		
    
    		if ($s5_domain15 == "yes") {
    
            $d_ca      = (isset($_POST['ca'])) ? 'ca' : ''; 
    
    		}
    
            
    
     		if ($s5_domain16 == "yes") {
    
            $d_it      = (isset($_POST['it'])) ? 'it' : ''; 
    
    		}       
    
            
    
    		if ($s5_domain17 == "yes") {
    
            $d_si      = (isset($_POST['si'])) ? 'si' : ''; 
    
    		}
    
    		        
    
            // Check domains only if the base name is big enough
    
            if (strlen($domainbase)>0){
    
    ?>
    
          <div id="caption" style="margin-top:8px; margin-bottom:8px; font-weight:bold"><?php echo $resulttext ?> :</div>
    
          <div id="result">
    
    
    
    <?php        
    
    
    
    			if ($s5_domain1 == "yes") {
    
                if (($d_com != '') || ($d_all != '') ) showDomainResult($domainbase.".com",'whois.crsnic.net','No match for');
    
    			}	
    
    			
    
    			if ($s5_domain2 == "yes") {
    
                if (($d_net != '') || ($d_all != '') ) showDomainResult($domainbase.".net",'whois.crsnic.net','No match for');
    
    			}	
    
    			
    
    			if ($s5_domain3 == "yes") {
    
                if (($d_info != '') || ($d_all != '') ) showDomainResult($domainbase.".info",'whois.afilias.net','NOT FOUND');
    
    			}	
    
    			
    
    			if ($s5_domain4 == "yes") {
    
                if (($d_org != '') || ($d_all != '') ) showDomainResult($domainbase.".org",'whois.publicinterestregistry.net','NOT FOUND');
    
    			}	
    
    			
    
    			if ($s5_domain5 == "yes") {
    
                if (($d_biz != '') || ($d_all != '') ) showDomainResult($domainbase.".biz",'whois.neulevel.biz','Not found:');
    
    			}	
    
    			
    
    			if ($s5_domain6 == "yes") {
    
                if (($d_couk != '') || ($d_all != '') ) showDomainResult($domainbase.".co.uk",'whois.nic.uk','No match for');
    
    			}	
    
    			
    
    			if ($s5_domain7 == "yes") {
    
                if (($d_name != '') || ($d_all != '') ) showDomainResult($domainbase.".name",'whois.nic.name','No match');
    
    			}	
    
    			
    
    			if ($s5_domain8 == "yes") {
    
                if (($d_cc != '') || ($d_all != '') ) showDomainResult($domainbase.".cc",'whois.nic.cc','No match');
    
    			}	
    
    			
    
    			if ($s5_domain9 == "yes") {
    
                if (($d_us != '') || ($d_all != '') ) showDomainResult($domainbase.".us",'whois.nic.us','Not found:');
    
    			}
    
    			
    
    			if ($s5_domain10 == "yes") {
    
                if (($d_tv != '') || ($d_all != '') ) showDomainResult($domainbase.".tv",'whois.nic.tv','No match for');
    
    			}
    
    			
    
    			if ($s5_domain11 == "yes") {
    
                if (($d_eu != '') || ($d_all != '') ) showDomainResult($domainbase.".eu",'whois.eu','FREE');
    
    			}
    
    			
    
    			if ($s5_domain12 == "yes") {
    
                if (($d_edu != '') || ($d_all != '') ) showDomainResult($domainbase.".edu",'whois.crsnic.net','No match for');
    
    			}
    
    			
    
    			if ($s5_domain13 == "yes") {
    
                if (($d_mobi != '') || ($d_all != '') ) showDomainResult($domainbase.".mobi",'whois.dotmobiregistry.net','NOT FOUND');
    
    			}
    
    			
    
    			if ($s5_domain14 == "yes") {
    
                if (($d_nl != '') || ($d_all != '') ) showDomainResult($domainbase.".nl",'whois.domain-registry.nl','free');
    
    			}
    
    			
    
    			if ($s5_domain15 == "yes") {
    
                if (($d_ca != '') || ($d_all != '') ) showDomainResult($domainbase.".ca",'whois.cira.ca','AVAIL');
    
    			}
    
    
    
    			if ($s5_domain16 == "yes") {
    
                if (($d_it != '') || ($d_all != '') ) showDomainResult($domainbase.".it",'whois.nic.it','No match for');
    
    			}
    
    			
    
    			if ($s5_domain17 == "yes") {
    
                if (($d_si != '') || ($d_all != '') ) showDomainResult($domainbase.".si",'whois.arnes.si','No entries found');
    
    			}			
    
    
    
    ?>
    
    
    
         </div>
    
    <?php            
    
            }
    
        }
    
    ?>    
    
    
    
        </div>
    

    Open in new window

    0
     

    Expert Comment

    by:KMETAVZER
    Maybe i have to add an interval between each socket connection to the whois server ?

    (button is placed on line 245 of attached file)
    0
     

    Expert Comment

    by:KMETAVZER
    Also a squeeze box that cover the page could be a good solution.
    Somebody know a good script that can be easly integrated into a joomla's template (into index.php)?
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone. Privacy Policy Terms of Use

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    "That which we persist in doing becomes easier, not that the task itself has become easier, but that our ability to perform it has improved." Ralph Waldo Emerson Introduction: One of the wonderful things about the web is that it makes it s…
    Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    875 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now