Ir para conteúdo
xdxddxd

Mudar de "OK" Para "Home" e "Cancelar" para "Estoque"

Recommended Posts

ao clicar em um botão eu gostaria de exibir um confirm no site, mas eu gostaria de Mudar de "OK" Para "Home" e "Cancelar" para "Estoque".

isso usando javascript puro, alguem pode me ajudar ?

já agradeço de já.

tem que usar algum plugin no site ou tem como fazer puro mesmo.

se quiser deixar só um link com o tutorial eu já agradeço, porém não achei nenhum do jeito que eu quero no google.

Compartilhar este post


Link para o post
Compartilhar em outros sites

com javascript puro não é possível.

 

plugins existem vários:

https://craftpip.github.io/jquery-confirm/

Compartilhar este post


Link para o post
Compartilhar em outros sites

@xdxddxd

 

É possível sim, segue o código:

 

<script>
function Redirect1(){
    if (document.getElementById('redirect1').value == "Ok"){
        document.getElementById('redirect1').value = "Home";
        document.getElementById('redirect1').disabled = ""
    } else {
	    if (document.getElementById('redirect1').value == "Home"){
            document.getElementById('redirect1').value = "Ok";
            document.getElementById('redirect1').disabled = ""
	    }
	}
}

function Redirect2(){
    if (document.getElementById('redirect2').value == "Cancel"){
        document.getElementById('redirect2').value = "Estoque";
        document.getElementById('redirect2').disabled = ""
    } else {
	    if (document.getElementById('redirect2').value == "Estoque"){
            document.getElementById('redirect2').value = "Cancel";
            document.getElementById('redirect2').disabled = ""
	    }
	}
}
</script>
<button onclick="Redirect1()">Check Button 1</button>
<input type="submit" id="redirect1" value="Ok" disabled>
<button onclick="Redirect2()">Check Button 2</button>
<input type="submit" id="redirect2" value="Cancel" disabled>

 

Agora se você quer que cada BOTÃO tenha uma FUNÇÃO diferente, exemplo, ao clicar no botão OK ele CONFIRME e no HOME ele redirecione para a página inicial, ai o que eu recomendo você a fazer é o seguinte.

 

Criar 4 FORMULÁRIOS 1 com o STYLE VISIBLE e os outros 3 HIDDEN ai conforme você clica no botão para validar uma ação que eu não sei qual é a regra do seu negócio, você apenas muda de HIDDEN para VISIBLE o formulário com a ação que você quer e coloca os outros 3 como HIDDEN e ai para o usuário cada botão tem uma chamada no ACTION diferente, podendo ser redirecionado para qualquer lugar para os seus 4 botões.

 

Espero ter ajudado.

 

Att.

Felipe Coutinho

Compartilhar este post


Link para o post
Compartilhar em outros sites

@xdxddxd

 

Seguindo um pouco a lógica do que eu falei, segue um código exemplo que fiz para demonstrar como exibir e esconder os formulários, basta você ir adaptando a sua necessidade e regra de negócio.

 

<!DOCTYPE HTML>
<html>
    <head>
    <!-- Meta -->
        <meta charset="UTF-8">
        <meta name="author" content="Felipe Guedes Coutinho Hashimoto">
        <meta name="description" content="Habilitando e Desabilitando Formulários">
        <meta name="keywords" content="Habilita Desabilita Formulário">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
        <style>
            #customers {
                font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
                border-collapse: collapse;
                width: 100%;
            }
            #customers td, #customers th {
			    background-color: #FAFAFA;
                border: 1px solid #ddd;
                padding: 8px;
            }
			#customers td:hover {
                background-color: #f5f5f5;
            }
            .shadow-1, button, .container {
                box-shadow: 0 1px 3px rgba(0, 0, 255, 0.12), 0 1px 2px rgba(0, 0, 255, 0.24);
            }
            .shadow-2, button:hover, .context_menu_pai, .box_login, .datepicker.dropdown-menu, .dialogbox, .overflow-menu ul {
                box-shadow: 0 2px 5px 0 rgba(0, 0, 255, 0.16), 0 2px 10px 0 rgba(0, 0, 255, 0.12);
            }
            .transition-1, button {
                transition: all .3s ease-out;
                transition-property: all;
                transition-duration: .3s;
                transition-timing-function: ease-out;
            }
            button {
                background-color: #FFFFFF;
                text-align: center
                border: 0;
                padding: 0px;
                width: 70px;
                height: 20px;
                display: inline-block;
                margin: 5px;
                cursor: pointer;
                border-radius: 4px;
            }
            input[type="text"], input[type="password"], input[type="search"] {
                box-shadow: 0 0 0 0;
                border: 0 none;
                outline: 0;
                border-radius: 5px;
                padding: 1px 8px;
                background-color: white;
                color: silver;
            }            
            input[type="text"]:focus, input[type="password"]:focus, input[type="search"]:focus {
                box-shadow: none;
                border: 1px solid;
                border-color: #97B0E6;
            }
		</style>
        <script type="text/javascript">
            function habilitar(e){
                if (e.value == "HabilitaOk"){
                    document.getElementById('div_form_Ok').style.display = "block";
                    document.getElementById('div_form_Home').style.display = "none";
                    document.getElementById('div_form_Estoque').style.display = "none";
                    document.getElementById('div_form_Cancel').style.display = "none";
                }
                if (e.value == "HabilitaHome"){
                    document.getElementById('div_form_Ok').style.display = "none";
                    document.getElementById('div_form_Home').style.display = "block";
                    document.getElementById('div_form_Estoque').style.display = "none";
                    document.getElementById('div_form_Cancel').style.display = "none";
                }
                if (e.value == "HabilitaEstoque"){
                    document.getElementById('div_form_Ok').style.display = "none";
                    document.getElementById('div_form_Home').style.display = "none";
                    document.getElementById('div_form_Estoque').style.display = "block";
                    document.getElementById('div_form_Cancel').style.display = "none";
                }
                if (e.value == "HabilitaCancel"){
                    document.getElementById('div_form_Ok').style.display = "none";
                    document.getElementById('div_form_Home').style.display = "none";
                    document.getElementById('div_form_Estoque').style.display = "none";
                    document.getElementById('div_form_Cancel').style.display = "block";
                }
            }
        </script>
    </head>	
	<body>
        <table border="0" id="customers">
		<tr>
		<td align="center"><button onClick="habilitar(this)" id="btn_ok"      value="HabilitaOk"      style="display:block">OK      </button></td>
        <td align="center"><button onClick="habilitar(this)" id="btn_home"    value="HabilitaHome"    style="display:block">Home    </button></td>
        <td align="center"><button onClick="habilitar(this)" id="btn_estoque" value="HabilitaEstoque" style="display:block">Estoque </button></td>
        <td align="center"><button onClick="habilitar(this)" id="btn_cancel"  value="HabilitaCancel"  style="display:block">Cancel  </button></td>
		</tr>
		</table>
		<br />
		<div id="div_form_Ok" style="display:block">
			<form method="post" action="incluir.php">
			<table border="0" id="customers">
			<tr><td colspan="2" align="center">Informações para incluir</td></tr>
			<tr><td align="right">Nome:  </td><td><input type="search"   id="Nome"  placeholder="Digite seu nome."  size="50" required autofocus /> </td></tr>
			<tr><td align="right">Senha: </td><td><input type="password" id="Senha" placeholder="Digite sua senha." size="50" required />           </td></tr>
			<tr><td colspan="2" align="center"><input type="submit" value="Ok"/></td></tr>
			</table>
			</form>
		</div>
		<div id="div_form_Home" style="display:none">
			<form method="post" action="index.php">
			<table border="0" id="customers">
			<tr><td colspan="2" align="center">Redirecionar para Home</td></tr>
			<tr><td align="center"><input type="submit" value="Home"/></td></tr>
			</table>
			</form>
		</div>
		<div id="div_form_Estoque" style="display:none">
			<form method="post" action="estoque.php">
			<table border="0" id="customers">
			<tr><td colspan="2" align="center">Verificar Estoque</td></tr>
			<tr><td align="center"><input type="submit" value="Estoque"/></td></tr>
			</table>
			</form>
		</div>
		<div id="div_form_Cancel" style="display:none">
			<form method="post" action="logout.php">
			<table border="0" id="customers">
			<tr><td colspan="2" align="center">Logout</td></tr>
			<tr><td align="center"><input type="submit" value="Cancel"/></td></tr>
			</table>
			</form>
		</div>
	</body>	
</html>

 

Aqui tem outro exemplo: Exibir Formulário Oculto com Botão.

 

Espero ter ajudado.

 

Att.

Felipe Coutinho

Compartilhar este post


Link para o post
Compartilhar em outros sites
On 10/22/2019 at 11:23 AM, Felipe Guedes Coutinho said:

@xdxddxd

 

Seguindo um pouco a lógica do que eu falei, segue um código exemplo que fiz para demonstrar como exibir e esconder os formulários, basta você ir adaptando a sua necessidade e regra de negócio.

 


<!DOCTYPE HTML>
<html>
    <head>
    <!-- Meta -->
        <meta charset="UTF-8">
        <meta name="author" content="Felipe Guedes Coutinho Hashimoto">
        <meta name="description" content="Habilitando e Desabilitando Formulários">
        <meta name="keywords" content="Habilita Desabilita Formulário">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
        <style>
            #customers {
                font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
                border-collapse: collapse;
                width: 100%;
            }
            #customers td, #customers th {
			    background-color: #FAFAFA;
                border: 1px solid #ddd;
                padding: 8px;
            }
			#customers td:hover {
                background-color: #f5f5f5;
            }
            .shadow-1, button, .container {
                box-shadow: 0 1px 3px rgba(0, 0, 255, 0.12), 0 1px 2px rgba(0, 0, 255, 0.24);
            }
            .shadow-2, button:hover, .context_menu_pai, .box_login, .datepicker.dropdown-menu, .dialogbox, .overflow-menu ul {
                box-shadow: 0 2px 5px 0 rgba(0, 0, 255, 0.16), 0 2px 10px 0 rgba(0, 0, 255, 0.12);
            }
            .transition-1, button {
                transition: all .3s ease-out;
                transition-property: all;
                transition-duration: .3s;
                transition-timing-function: ease-out;
            }
            button {
                background-color: #FFFFFF;
                text-align: center
                border: 0;
                padding: 0px;
                width: 70px;
                height: 20px;
                display: inline-block;
                margin: 5px;
                cursor: pointer;
                border-radius: 4px;
            }
            input[type="text"], input[type="password"], input[type="search"] {
                box-shadow: 0 0 0 0;
                border: 0 none;
                outline: 0;
                border-radius: 5px;
                padding: 1px 8px;
                background-color: white;
                color: silver;
            }            
            input[type="text"]:focus, input[type="password"]:focus, input[type="search"]:focus {
                box-shadow: none;
                border: 1px solid;
                border-color: #97B0E6;
            }
		</style>
        <script type="text/javascript">
            function habilitar(e){
                if (e.value == "HabilitaOk"){
                    document.getElementById('div_form_Ok').style.display = "block";
                    document.getElementById('div_form_Home').style.display = "none";
                    document.getElementById('div_form_Estoque').style.display = "none";
                    document.getElementById('div_form_Cancel').style.display = "none";
                }
                if (e.value == "HabilitaHome"){
                    document.getElementById('div_form_Ok').style.display = "none";
                    document.getElementById('div_form_Home').style.display = "block";
                    document.getElementById('div_form_Estoque').style.display = "none";
                    document.getElementById('div_form_Cancel').style.display = "none";
                }
                if (e.value == "HabilitaEstoque"){
                    document.getElementById('div_form_Ok').style.display = "none";
                    document.getElementById('div_form_Home').style.display = "none";
                    document.getElementById('div_form_Estoque').style.display = "block";
                    document.getElementById('div_form_Cancel').style.display = "none";
                }
                if (e.value == "HabilitaCancel"){
                    document.getElementById('div_form_Ok').style.display = "none";
                    document.getElementById('div_form_Home').style.display = "none";
                    document.getElementById('div_form_Estoque').style.display = "none";
                    document.getElementById('div_form_Cancel').style.display = "block";
                }
            }
        </script>
    </head>	
	<body>
        <table border="0" id="customers">
		<tr>
		<td align="center"><button onClick="habilitar(this)" id="btn_ok"      value="HabilitaOk"      style="display:block">OK      </button></td>
        <td align="center"><button onClick="habilitar(this)" id="btn_home"    value="HabilitaHome"    style="display:block">Home    </button></td>
        <td align="center"><button onClick="habilitar(this)" id="btn_estoque" value="HabilitaEstoque" style="display:block">Estoque </button></td>
        <td align="center"><button onClick="habilitar(this)" id="btn_cancel"  value="HabilitaCancel"  style="display:block">Cancel  </button></td>
		</tr>
		</table>
		<br />
		<div id="div_form_Ok" style="display:block">
			<form method="post" action="incluir.php">
			<table border="0" id="customers">
			<tr><td colspan="2" align="center">Informações para incluir</td></tr>
			<tr><td align="right">Nome:  </td><td><input type="search"   id="Nome"  placeholder="Digite seu nome."  size="50" required autofocus /> </td></tr>
			<tr><td align="right">Senha: </td><td><input type="password" id="Senha" placeholder="Digite sua senha." size="50" required />           </td></tr>
			<tr><td colspan="2" align="center"><input type="submit" value="Ok"/></td></tr>
			</table>
			</form>
		</div>
		<div id="div_form_Home" style="display:none">
			<form method="post" action="index.php">
			<table border="0" id="customers">
			<tr><td colspan="2" align="center">Redirecionar para Home</td></tr>
			<tr><td align="center"><input type="submit" value="Home"/></td></tr>
			</table>
			</form>
		</div>
		<div id="div_form_Estoque" style="display:none">
			<form method="post" action="estoque.php">
			<table border="0" id="customers">
			<tr><td colspan="2" align="center">Verificar Estoque</td></tr>
			<tr><td align="center"><input type="submit" value="Estoque"/></td></tr>
			</table>
			</form>
		</div>
		<div id="div_form_Cancel" style="display:none">
			<form method="post" action="logout.php">
			<table border="0" id="customers">
			<tr><td colspan="2" align="center">Logout</td></tr>
			<tr><td align="center"><input type="submit" value="Cancel"/></td></tr>
			</table>
			</form>
		</div>
	</body>	
</html>

 

Aqui tem outro exemplo: Exibir Formulário Oculto com Botão.

 

Espero ter ajudado.

 

Att.

Felipe Coutinho

 Obrigado, peguei o que você fez e modifiquei um pouco e funcionou.

Compartilhar este post


Link para o post
Compartilhar em outros sites

Crie uma conta ou entre para comentar

Você precisar ser um membro para fazer um comentário

Criar uma conta

Crie uma nova conta em nossa comunidade. É fácil!

Crie uma nova conta

Entrar

Já tem uma conta? Faça o login.

Entrar Agora

  • Conteúdo Similar

    • Por Jack Oliveira
      Ola estou fazendo um instalador de banco de dados 
       
      em parte funciona  
       
      Mas quando uso o
      <<<HTML
       
      HTML;
       
      Ele fica com estas informações no top
       
      7.4 ao 8.38.0.28512MOnOnOnOffOffOnOffOffOnOnOnOnOnprogress-bar-success
       
      <?php $MeuHtml = <<<HTML <!DOCTYPE html> <html> <head><meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>Instalação {$autor}</title> <link rel="icon" href="{$urlApi}api/allinstall/assets/icone.png?v={$versao}" sizes="32x32"> <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport"> <link rel="stylesheet" href="{$urlApi}api/allinstall/assets/css/app.css?v={$versao}"> <style type="text/css"> .license { background-color: #FFF; height: 400px; width: 100%; margin: 10px; } .form-control{ margin-bottom: 5px; } #primary{background: #FF6403} .paper-card{background: #272c33} .card{background: none;} .sw-theme-circles>ul.step-anchor:before{background-color: #30363d} .sw-theme-circles>ul.step-anchor>li>a{border: 3px solid #30363d} .sw-theme-circles>ul.step-anchor>li>a{background: #f5f5f5; min-width: 50px; height: 50px; text-align: center; -webkit-box-shadow: inset 0 0 0 3px #fff!important; box-shadow: inset 0 0 0 3px #fff!important; text-decoration: none; outline-style: none; z-index: 99; color: #999; background: #fff; line-height: 2; font-weight: bold;} .sw-theme-circles>ul.step-anchor>li{margin-left: 15%;} .card-header{border-bottom: 0} .table-striped tbody tr:nth-of-type(odd){background-color: #30363d;} .table-bordered{border: 1px solid #30363d;} .table-bordered td, .table-bordered th { border: 1px solid #30363d; } </style> </head> <body class="light loaded"> <div id="app"> <main> <div id="primary" class="p-t-b-100 height-full"> <div class="container"> <div class="row"> <div class="col-lg-8 mx-md-auto paper-card"> <div class="text-center"> <img class="img-responsive" src="{$urlApi}api/allinstall/assets/{$imagem}?v={$versao}"> <p><strong><H3>Instalação {$projeto} | V: {$versao}</H3></strong></p> </div> HTML; if (!isset($_GET['step']) || $_GET['step'] == '1') { $MeuHtml .= <<<HTML <div class="card no-b"> <div class="card-header pb-0"> <div class="stepper sw-main sw-theme-circles" id="smartwizard" data-options='{ "theme":"sw-theme-circles", "transitionEffect":"fade" }'> <ul class="nav step-anchor"> <li><a href="#step-1y">1</a></li> <li><a href="#step-2y">2</a></li> <li><a href="#step-3y">3</a></li> <li><a href="#step-4y">4</a></li> </ul> </div> </div> <div class="card-body"> <h6><b>Configurações do Servidor</b></h6><br> <table class="table table-condensed table-bordered table-striped"> <tr> <th>Função / Extensão</th> <th>Config. Necessária</th> <th>Config. Atual</th> <th width="50px">Status</th> </tr> <tr> <td>Versão do PHP</td> <td> HTML; echo $php7. ' ao '.$php8; $MeuHtml .= <<<HTML </td> <td> HTML; echo phpversion(); $MeuHtml .= <<<HTML </td> <td> HTML; if(phpversion() >= $php7 && phpversion() <= $php8) { $i = $i + 1; echo '<button type="button" class="btn btn-success"><i class="icon-check"></i></button>'; } else { echo '<button type="button" class="btn btn-danger"><i class="icon-close"></i></button>'; } $MeuHtml .= <<<HTML </td> </tr> HTML; $MeuHtml .= <<<HTML <tr> <td>Memória do PHP</td> <td>128MB</td> <td> HTML; echo $mem = ini_get('memory_limit'); $MeuHtml .= <<<HTML </td> <td> HTML; if($mem >= 128) { $i = $i + 1; echo '<button type="button" class="btn btn-success"><i class="icon-check"></i></button>'; } else { echo '<button type="button" class="btn btn-danger"><i class="icon-close"></i></button>'; } $MeuHtml .= <<<HTML </td> </tr> <tr> <td>cURL</td> <td>On</td> <td> HTML; if(function_exists('curl_init')) { echo 'On'; } else { echo 'Off'; } $MeuHtml .= <<<HTML </td> <td> HTML; if(function_exists('curl_init')) { $i = $i + 1; echo '<button type="button" class="btn btn-success"><i class="icon-check"></i></button>'; } else { echo '<button type="button" class="btn btn-danger"><i class="icon-close"></i></button>'; } $MeuHtml .= <<<HTML </td> </tr> <tr> <td>Allow URL fopen</td> <td>On</td> <td> HTML; if(ini_get('allow_url_fopen')) { echo 'On'; } else { echo 'Off'; } $MeuHtml .= <<<HTML </td> <td> HTML; if(ini_get('allow_url_fopen')) { $i = $i + 1; echo '<button type="button" class="btn btn-success"><i class="icon-check"></i></button>'; } else { echo '<button type="button" class="btn btn-danger"><i class="icon-close"></i></button>'; } $MeuHtml .= <<<HTML </td> </tr> <tr> <td>File Get Contents</td> <td>On</td> <td> HTML; if(function_exists('file_get_contents')) { echo 'On'; } else { echo 'Off'; } $MeuHtml .= <<<HTML </td> <td> HTML; if(function_exists('file_get_contents')) { $i = $i + 1; echo '<button type="button" class="btn btn-success"><i class="icon-check"></i></button>'; } else { echo '<button type="button" class="btn btn-danger"><i class="icon-close"></i></button>'; } $MeuHtml .= <<<HTML </td> </tr> <tr> <td>Sessão Auto Start</td> <td>Off</td> <td> HTML; if(ini_get('session_auto_start')) { echo 'On'; } else { echo 'Off'; } $MeuHtml .= <<<HTML </td> <td> HTML; if(!ini_get('session_auto_start')) { $i = $i + 1; echo '<button type="button" class="btn btn-success"><i class="icon-check"></i></button>'; } else { echo '<button type="button" class="btn btn-danger"><i class="icon-close"></i></button>'; } $MeuHtml .= <<<HTML </td> </tr> <tr> <td>Safe Mode</td> <td>Off</td> <td> HTML; if(ini_get('safe_mode')) { echo 'On'; } else { echo 'Off'; } $MeuHtml .= <<<HTML </td> <td> HTML; if(!ini_get('safe_mode')) { $i = $i + 1; echo '<button type="button" class="btn btn-success"><i class="icon-check"></i></button>'; } else { echo '<button type="button" class="btn btn-danger"><i class="icon-close"></i></button>'; } $MeuHtml .= <<<HTML </td> </tr> <tr> <td>Short Open Tags</td> <td>On</td> <td> HTML; if(ini_get('short_open_tag')) { echo 'On'; } else { echo 'Off'; } $MeuHtml .= <<<HTML </td> <td> HTML; if(ini_get('short_open_tag')) { $i = $i + 1; echo '<button type="button" class="btn btn-success"><i class="icon-check"></i></button>'; } else { echo '<button type="button" class="btn btn-danger"><i class="icon-close"></i></button>'; } $MeuHtml .= <<<HTML </td> </tr> <tr> <td>Magic Quotes GPC</td> <td>Off</td> <td> HTML; if(ini_get('magic_quotes_gpc')) { echo 'On'; } else { echo 'Off'; } $MeuHtml .= <<<HTML </td> <td> HTML; if(!ini_get('magic_quotes_gpc')) { $i = $i + 1; echo '<button type="button" class="btn btn-success"><i class="icon-check"></i></button>'; } else { echo '<button type="button" class="btn btn-danger"><i class="icon-close"></i></button>'; } $MeuHtml .= <<<HTML </td> </tr> <tr> <td>Register Globals</td> <td>Off</td> <td> HTML; if(ini_get('register_globals')) { echo 'On'; } else { echo 'Off'; } $MeuHtml .= <<<HTML </td> <td> HTML; if(!ini_get('register_globals')) { $i = $i + 1; echo '<button type="button" class="btn btn-success"><i class="icon-check"></i></button>'; } else { echo '<button type="button" class="btn btn-danger"><i class="icon-close"></i></button>'; } $MeuHtml .= <<<HTML </td> </tr> <tr> <td>PHPMail</td> <td>On</td> <td> HTML; if(function_exists('mail')) { echo 'On'; } else { echo 'Off'; } $MeuHtml .= <<<HTML </td> <td> HTML; if(function_exists('mail')) { $i = $i + 1; echo '<button type="button" class="btn btn-success"><i class="icon-check"></i></button>'; } else { $i = $i + 1; echo '<button type="button" class="btn btn-danger"><i class="icon-close"></i></button>'; } $MeuHtml .= <<<HTML </td> </tr> <tr> <td>MySQLi</td> <td>On</td> <td> HTML; if(extension_loaded('mysqli')) { echo 'On'; } else { echo 'Off'; } $MeuHtml .= <<<HTML </td> <td> HTML; if(extension_loaded('mysqli')) { $i = $i + 1; echo '<button type="button" class="btn btn-success"><i class="icon-check"></i></button>'; } else { echo '<button type="button" class="btn btn-danger"><i class="icon-close"></i></button>'; } $MeuHtml .= <<<HTML </td> </tr> <tr> <td>ZIP</td> <td>On</td> <td> HTML; if(extension_loaded('zip')) { echo 'On'; } else { echo 'Off'; } $MeuHtml .= <<<HTML </td> <td> HTML; if(extension_loaded('zip')) { $i = $i + 1; echo '<button type="button" class="btn btn-success"><i class="icon-check"></i></button>'; } else { echo '<button type="button" class="btn btn-danger"><i class="icon-close"></i></button>'; } $MeuHtml .= <<<HTML </td> </tr> <tr> <td>MBString</td> <td>On</td> <td> HTML; if(extension_loaded('mbstring')) { echo 'On'; } else { echo 'Off'; } $MeuHtml .= <<<HTML </td> <td> HTML; if(extension_loaded('mbstring')) { $i = $i + 1; echo '<button type="button" class="btn btn-success"><i class="icon-check"></i></button>'; } else { echo '<button type="button" class="btn btn-danger"><i class="icon-close"></i></button>'; } $MeuHtml .= <<<HTML </td> </tr> <tr> <td>XML</td> <td>On</td> <td> HTML; if(extension_loaded('libxml')) { echo 'On'; } else { echo 'Off'; } $MeuHtml .= <<<HTML </td> <td> HTML; if(extension_loaded('libxml')) { $i = $i + 1; echo '<button type="button" class="btn btn-success"><i class="icon-check"></i></button>'; } else { echo '<button type="button" class="btn btn-danger"><i class="icon-close"></i></button>'; } $MeuHtml .= <<<HTML </td> </tr> </table> <hr> <h6><b>Diretórios e Permissões de Arquivos</b></h6><br> <table class="table table-condensed table-bordered table-striped"> <tr> <th>Diretório</th> <th style="width: 40px">Status</th> </tr> <tr> <td>database</td> <td> HTML; if(is_writable('database')) { $i = $i + 1; echo '<button type="button" class="btn btn-success"><i class="icon-check"></i></button>'; } else { echo '<button type="button" class="btn btn-danger"><i class="icon-close"></i></button>'; } $MeuHtml .= <<<HTML </td> </tr> </table> <hr> <h6><b>Pontuação / Compatibilidade</b></h6><br> <div class="progress"> <div class="progress-bar progress-bar-striped progress-bar-animated HTML; echo ProgressBar(substr(VerificaPontuacao($i,'16'),0,4)); $PontPorce = VerificaPontuacao($i,'16'); $pont100 = substr(VerificaPontuacao($i,'16'),0,4); $MeuHtml .= <<<HTML " role="progressbar" aria-valuemax="100" style="width: {$PontPorce}%;"> <strong>{$pont100} / 100</strong> </div> </div> <center> <br> <button class="btn btn-primary" onclick="document.location.href='{$URL}?step=1';">Verificar</button> <button class="btn btn-primary" onclick="document.location.href='{$URL}?step=2';">Próximo</button> </center> </div> </div> HTML; } elseif (isset($_GET['step']) && $_GET['step'] == '2') { $MeuHtml .= <<<HTML <div class="card no-b"> <div class="card-header pb-0"> <div class="stepper sw-main sw-theme-circles" id="smartwizard" data-options='{ "theme":"sw-theme-circles", "transitionEffect":"fade" }'> <ul class="nav step-anchor"> <li><a href="#step-1y">1</a></li> <li class="active"><a href="#step-2y">2</a></li> <li><a href="#step-3y">3</a></li> <li><a href="#step-4y">4</a></li> </ul> </div> </div> <div class="card-body "> <iframe src="{$urlApi}api/allinstall/termos.php{$Frame}" class="license" frameborder="0" scrolling="auto"></iframe> <form action="setup.php"> <input type="hidden" name="step" value="3"> <label><input type="checkbox" required=""> Sim, eu aceito</label> <center> <br> <a href="javascript:history.back()"><button class="btn btn-primary">Voltar</button></a> <button class="btn btn-primary" type="submit">Próximo</button> </center> </form> </div> </div> HTML; } elseif (isset($_GET['step']) && $_GET['step'] == '3') { $MeuHtml .= <<<HTML <div class="card no-b"> <div class="card-header pb-0"> <div class="stepper sw-main sw-theme-circles" id="smartwizard" data-options='{ "theme":"sw-theme-circles", "transitionEffect":"fade" }'> <ul class="nav step-anchor"> <li><a href="#step-1y">1</a></li> <li class="active"><a href="#step-2y">2</a></li> <li class="active"><a href="#step-3y">3</a></li> <li><a href="#step-4y">4</a></li> </ul> </div> </div> <div class="card-body"> <form method="post" action="?InstallDB"> <h6><b>1. MySQL - Configuração do Banco de Dados</b></h6><hr> <div class="form-group row"> <label class="col-sm-3 control-label">MySQL Host:</label> <div class="col-sm-9"> <input class="form-control" name="dbhost" value="localhost" required> </div> </div> <div class="form-group row"> <label class="col-sm-3 control-label">Usuário MySQL:</label> <div class="col-sm-9"> <input class="form-control" name="dbuser" required> </div> </div> <div class="form-group row"> <label class="col-sm-3 control-label">Senha MySQL:</label> <div class="col-sm-9"> <input class="form-control" name="dbpass"> </div> </div> <div class="form-group row"> <label class="col-sm-3 control-label">Nome do Banco MySQL:</label> <div class="col-sm-9"> <input class="form-control" name="dbname" required> </div> </div> <h6><b>2. Configuração Comum</b></h6><hr> <div class="form-group row"> <label class="col-sm-3 control-label">Nome do Site:</label> <div class="col-sm-9"> <input class="form-control" name="nomesite" required> </div> </div> <div class="form-group row"> <label class="col-sm-3 control-label">URL do Site:</label> <div class="col-sm-9"> <input class="form-control" name="urlsite" value="{$urlsite}" required> </div> </div> <div class="form-group row"> <label class="col-sm-3 control-label">URL de Instalação:</label> <div class="col-sm-9"> <input class="form-control" name="siteurl" value="{$siteurl}" required> </div> </div> <div class="form-group row"> <label class="col-sm-3 control-label">Extensão:</label> <div class="col-sm-9"> <select class="form-control" name="extensao" required> <option value=""> Selecionar Extensão </option> <option value="1"> MYSQLI </option> <option value="2"> PDO </option> </select> </div> </div> <div class="form-group row"> <label class="col-sm-3 control-label">Define TimeZone:</label> <div class="col-sm-9"> <select class="form-control" name="timezone" id="timezone"> HTML; foreach ($timezones as $timezone) : echo '<option value="'.$timezone.'" '.$timezone === $current_timezone ? 'selected' : ''.'> '.$timezone.' </option>'; endforeach; $MeuHtml .= <<<HTML </select> </div> </div> <div class="form-group row"> <label class="col-sm-3 control-label">E-mail:</label> <div class="col-sm-9"> <input class="form-control" name="email" required> <em>Mesmo e-mail cadastrado em nosso Site.</em> </div> </div> <h6><b>3. Configuração do Administrador</b></h6><hr> <div class="form-group row"> <label class="col-sm-3 control-label">Nome do Usuário:</label> <div class="col-sm-9"> <input class="form-control" name="usuario" required> </div> </div> <div class="form-group row"> <label class="col-sm-3 control-label">Login:</label> <div class="col-sm-9"> <input class="form-control" name="login" required> </div> </div> <div class="form-group row"> <label class="col-sm-3 control-label">Senha:</label> <div class="col-sm-9"> <input class="form-control" type="password" name="senha" required> </div> </div> <div class="form-group row"> <label class="col-sm-3 control-label">Senha[confimação]:</label> <div class="col-sm-9"> <input class="form-control" type="password" name="senhaconfirm" required> </div> </div> <center> <a class="btn btn-primary" href="javascript:history.back()">Voltar</a> <button class="btn btn-primary">Próximo</button> </center> </form> </div> </div> HTML; } elseif (isset($_GET['step']) && $_GET['step'] == '4') { $MeuHtml .= <<<HTML <div class="card no-b"> <div class="card-header pb-0"> <div class="stepper sw-main sw-theme-circles" id="smartwizard" data-options='{ "theme":"sw-theme-circles", "transitionEffect":"fade" }'> <ul class="nav step-anchor"> <li><a href="#step-1y">1</a></li> <li class="active"><a href="#step-2y">2</a></li> <li class="active"><a href="#step-3y">3</a></li> <li class="active"><a href="#step-4y">4</a></li> </ul> </div> </div> <div class="card-body"> <div> <h4><b>Instalação realizada com sucesso!</b></h4> <p>Agora você poderá utilizar o seu {$projeto}, em caso de dúvidas entre em contato com o suporte: <b>{$emailautor}</b></p> </div> <center> <form action="{$URL}?step=4" method="post"> <button type="submit" name="realizar_login" class="btn btn-primary">Realizar Login</button> </form> </center> </div> </div> HTML; } if (isset($_POST['realizar_login'])) { // Deletar os arquivos @unlink('setup.php'); @unlink($URL); @unlink('termos.php'); @unlink('database/BD.sql'); @unlink('controller/setup.php'); // Redirecionar para a página de login ou outra página desejada header('Location: login.php?finish'); exit; } $MeuHtml .= <<<HTML <div class="box-footer"> <center> Todos os Direitos Reservados {$autor} </center> </div> </div> </div> </div> </div> </main> </div> <script src="{$urlApi}api/allinstall/assets/js/app.js"></script> </body> </html> HTML; echo $MeuHtml;  
    • Por Jack Oliveira
      Ola pessoal, boa noite a todos
       
      Bom é o seguinte tenho um codigo html onde selecione um modelo de site para poder criar na base selecionada, ele criar ate então, mas ele esta pegando somente o index.html
      Mas quero que ele salva junto ao novo projeto o css, js, img, images, assets e fonts, quando faço os ajuste para que pega tudo isso ele me da erro ao salvar 
      Vou mostra parte do html onde faz a seleção dos modelos
       
      <!-- new page modal--> <div class="modal fade" id="new-page-modal" tabindex="-1" role="dialog"> <div class="modal-dialog" role="document"> <form id="newPageForm" method="POST" action="save.php"> <div class="modal-content"> <div class="modal-header"> <h6 class="modal-title text-primary fw-normal"><i class="la la-lg la-file"></i> Nova página</h6> <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"> </button> </div> <div class="modal-body text"> <div class="mb-3 row" data-key="type"> <label class="col-sm-3 col-form-label"> Modelo <abbr title="O conteúdo deste modelo será usado como ponto de partida para o novo modelo"> <i class="la la-lg la-question-circle text-primary"></i> </abbr> </label> <div class="col-sm-9 input"> <div> <select class="form-select" name="startTemplateUrl"> <option value="themes/modelo-branco/branco-template.html">Modelo em branco</option> <option value="themes/modelo1/index.html">Modelo 1 de L2</option> <option value="themes/modelo2/index.html">Modelo 3 de L2</option> <option value="themes/modelo3/index.html">Modelo 3 de L2 </option> </select> </div> </div> </div> <div class="mb-3 row" data-key="href"> <label class="col-sm-3 col-form-label">Nome da página</label> <div class="col-sm-9 input"> <div> <input name="title" type="text" value="Minha página" class="form-control" placeholder="Minha página" required> </div> </div> </div> <div class="mb-3 row" data-key="href"> <label class="col-sm-3 col-form-label">Nome do arquivo</label> <div class="col-sm-9 input"> <div> <input name="file" type="text" value="my-page.html" class="form-control" placeholder="index.html" required> </div> </div> </div> <div class="mb-3 row" data-key="href"> <label class="col-sm-3 col-form-label">Salvar na pasta</label> <div class="col-sm-9 input"> <div> <input name="folder" type="text" value="my-pages" class="form-control" placeholder="/" required> </div> </div> </div> </div> <div class="modal-footer"> <button class="btn btn-secondary btn-lg" type="reset" data-bs-dismiss="modal"><i class="la la-times"></i> Cancelar</button> <button class="btn btn-primary btn-lg" type="submit"><i class="la la-check"></i> Criar página</button> </div> </div> </form> </div> </div> A ideia aqui é salvar tudo que tiver depois do themes/demo1/
      quando ele salva so salva 
      my-pasta/index.html
      e quando for salva ele salva dentro de um pasta Projetos/MeuSite1
      Projetos/MeuSite2  e assim vai
      Este é o save.php
       
      <?php define('MAX_FILE_LIMIT', 1024 * 1024 * 2);//Tamanho máximo de arquivo HTML de 2 megabytes define('ALLOW_PHP', false);//verifique se o html salvo contém tag php e não salve se não for permitido define('ALLOWED_OEMBED_DOMAINS', [ 'https://www.youtube.com/', 'https://www.vimeo.com/', 'https://www.twitter.com/' ]);//carregar URLs apenas de sites permitidos para oembed function sanitizeFileName($file, $allowedExtension = 'html') { $basename = basename($file); $disallow = ['.htaccess', 'passwd']; if (in_array($basename, $disallow)) { showError('Nome de arquivo não permitido!'); return ''; } //sanitize, remova o ponto duplo .. e remova os parâmetros get, se houver $file = preg_replace('@\?.*$@' , '', preg_replace('@\.{2,}@' , '', preg_replace('@[^\/\\a-zA-Z0-9\-\._]@', '', $file))); if ($file) { $file = __DIR__ . DIRECTORY_SEPARATOR . $file; } else { return ''; } //permitir apenas extensão .html if ($allowedExtension) { $file = preg_replace('/\.[^.]+$/', '', $file) . ".$allowedExtension"; } return $file; } function showError($error) { header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error', true, 500); die($error); } function validOembedUrl($url) { foreach (ALLOWED_OEMBED_DOMAINS as $domain) { if (strpos($url, $domain) === 0) { return true; } } return false; } $html = ''; $file = ''; $action = ''; if (isset($_POST['startTemplateUrl']) && !empty($_POST['startTemplateUrl'])) { $startTemplateUrl = sanitizeFileName($_POST['startTemplateUrl']); $html = ''; if ($startTemplateUrl) { $html = file_get_contents($startTemplateUrl); } } else if (isset($_POST['html'])){ $html = substr($_POST['html'], 0, MAX_FILE_LIMIT); if (!ALLOW_PHP) { //if (strpos($html, '<?php') !== false) { if (preg_match('@<\?php|<\? |<\?=|<\s*script\s*language\s*=\s*"\s*php\s*"\s*>@', $html)) { showError('PHP não permitido!'); } } } if (isset($_POST['file'])) { $file = sanitizeFileName($_POST['file']); } if (isset($_GET['action'])) { $action = htmlspecialchars(strip_tags($_GET['action'])); } if ($action) { //ações do gerenciador de arquivos, excluir e renomear switch ($action) { case 'rename': $newfile = sanitizeFileName($_POST['newfile']); if ($file && $newfile) { if (rename($file, $newfile)) { echo "Arquivo '$file' renomeado para '$newfile'"; } else { showError("Erro ao renomear arquivo '$file' renomeado para '$newfile'"); } } break; case 'delete': if ($file) { if (unlink($file)) { echo "Arquivo '$file' excluído"; } else { showError("Erro ao excluir arquivo '$file'"); } } break; case 'saveReusable': //bloco ou seção $type = $_POST['type'] ?? false; $name = $_POST['name'] ?? false; $html = $_POST['html'] ?? false; if ($type && $name && $html) { $file = sanitizeFileName("$type/$name"); if ($file) { $dir = dirname($file); if (!is_dir($dir)) { echo "$dir pasta não existe\n"; if (mkdir($dir, 0777, true)) { echo "$dir pasta foi criada\n"; } else { showError("Erro ao criar pasta '$dir'\n"); } } if (file_put_contents($file, $html)) { echo "Arquivo salvo '$file'"; } else { showError("Erro ao salvar arquivo '$file'\nAs possíveis causas são falta de permissão de gravação ou caminho de arquivo incorreto!"); } } else { showError('Nome de arquivo inválido!'); } } else { showError("Faltam dados de elementos reutilizáveis!\n"); } break; case 'oembedProxy': $url = $_GET['url'] ?? ''; if (validOembedUrl($url)) { header('Content-Type: application/json'); echo file_get_contents($url); } else { showError('URL inválida!'); } break; default: showError("Ação inválida '$action'!"); } } else { //salvar pagina if ($html) { if ($file) { $dir = dirname($file); if (!is_dir($dir)) { echo "$dir pasta não existe\n"; if (mkdir($dir, 0777, true)) { echo "$dir pasta foi criada\n"; } else { showError("Erro ao criar pasta '$dir'\n"); } } if (file_put_contents($file, $html)) { echo "Arquivo salvo '$file'"; } else { showError("Erro ao salvar arquivo '$file'\nAs possíveis causas são falta de permissão de gravação ou caminho de arquivo incorreto!"); } } else { showError('O nome do arquivo está vazio!'); } } else { showError('O conteúdo HTML está vazio!'); } } Espero que possam entender o que preciso aqui....  fico no aguardo!  quando eu tento mudar a forma de salva no php, ele me da erro de que não foi salvo, e volta ao orginal como esta ai acima ele salva, talvez eu esteja escapando alguma coisa que não estou vendo.... 
    • Por violin101
      Caros amigos, saudações.
       
      Estou com uma pequena dúvida, referente a PEGAR AUTOMATICAMENTE a HORA e alimentar o campo INPUT.
       
      Tenho uma rotina, que estava aparentemente funcionando corretamente, mas agora estou tendo problema.
       
      A rotina, pega a HORA atual e informa automaticamente o INPUT, não estou entendendo porque agora não está mais fazendo.

      Abaixo a rotina.

       
      <div class="col-lg-3"> <label for="cotaHrsinicio">Hora da Abertura<span class="required">*</span></label> <div class="controls"> <input type="time" id="cotaHrsinicio" name="cotaHrsinicio" class="form-control" style="width:100%;" value="" /> <!-- NESSE INPUT A ROTINA INFORMA A DATA ATUAL --> </div> </div>  
       
      function date_time() { var date = new Date(); //var am_pm = "AM"; var hour = date.getHours(); /* if(hour>=12){ am_pm = "PM"; } */ if (hour == 0) { hour = 12; } if(hour<12){ hour = hour - 12; } if(hour>12){ hour + 12; } if(hour<10){ hour = "0"+hour; } var minute = date.getMinutes(); if (minute<10){ minute = "0"+minute; } var sec = date.getSeconds(); if(sec<10){ sec = "0"+sec; } /* *Formato da Hora (h:m:s) * Passar para a Variável: Hora Atual */ var cotaHrsinicio = document.getElementById("cotaHrsinicio").value = hour+":"+minute; }
      Grato,
       
      Cesar

       
    • Por luiz monteiro
      Bom dia.
      Estou precisando formatar um campo de entrada type text somente para numero com a seguinte formatação.
      se menor que 999 mostrar dessa forma mesmo, nesse caso seria para centena.dezena.unidade. Tipo 001 até 009 depois 010 até 099 depois 100 até 999
      de 1.000 até 999.999  mostrar com o ponto, nesse caso seria para milhar.centena.dezena.unidade. Tipo 001.000 até 001.999 e assim por diante.
      de 1.000.000 até 9.999.000, nesse caso seria para milhão.milhar.centena.dezena.unidade. aqui mesma ideia....
      Parecidos com aqueles campos de preço, que ao digitar os zeros ficam a esquerda até o valor atingirem a unidade correspondente.
       
      Tentei adaptar esse que encontrei na net.
      function moeda(a, e, r, t) { let n = "" , h = j = 0 , u = tamanho2 = 0 , l = ajd2 = "" , o = window.Event ? t.which : t.keyCode; if (13 == o || 8 == o) return !0; if (n = String.fromCharCode(o), -1 == "0123456789".indexOf(n)) return !1; for (u = a.value.length, h = 0; h < u && ("0" == a.value.charAt(h) || a.value.charAt(h) == r); h++) ; for (l = ""; h < u; h++) -1 != "0123456789".indexOf(a.value.charAt(h)) && (l += a.value.charAt(h)); if (l += n, 0 == (u = l.length) && (a.value = ""), 1 == u && (a.value = "0" + r + "0" + l), 2 == u && (a.value = "0" + r + l), u > 2) { for (ajd2 = "", j = 0, h = u - 3; h >= 0; h--) 3 == j && (ajd2 += e, j = 0), ajd2 += l.charAt(h), j++; for (a.value = "", tamanho2 = ajd2.length, h = tamanho2 - 1; h >= 0; h--) a.value += ajd2.charAt(h); a.value += r + l.substr(u - 2, u) } return !1 } Mas sem sucesso.
       
      Grato por enquanto.
       
       
       
    • Por Giovanird
      O script abaixo atualiza a página (centro.php) a cada um minuto e dentro desta página terei uma div que não poderá ser atualizada.
      Tentei colocar esta div como pagina com setInterval de 100 minutos porem ao dar o refresh no centro.php  tudo vai junto.  Será que isto é possivel?

      Desde já meu muito obrigado!
      <script> function atualiza(){ var url = 'centro.php'; $.get(url, function(dataReturn) { $('#centro').html(dataReturn); }); } setInterval("atualiza()",60000); </script>  

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.