Ir para conteúdo
Fórum Script Brasil
  • 0

Página com opção de cor


Dracom

Pergunta

Pagina com opsao de cor

OBS:aceita somente as cores:verde,preto,azul,amarelo,branco,vermelho,rosa.

<html>
<script>
var cor=window.prompt("digite a cor do documento","cor");
if(cor=="verde"){
document.bgColor="green";
}
if(cor=="preto"){
document.bgColor="black";
}
if(cor=="azul"){
document.bgColor="blue";
}
if(cor=="amarelo"){
document.bgColor="yelow";
}
if(cor=="branco"){
}
if(cor=="vermelho"){
document.bgColor="red";
}
if(cor=="rosa"){
document.bgColor="pink";
}


</script>
</html>

Link para o comentário
Compartilhar em outros sites

6 respostass a esta questão

Posts Recomendados

  • 0

Mudando a cor através de radio buttons

Uma outra forma de se fazer o proposto pelo Dracom é esta:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
function fundo(cor){
  document.bgColor = cor;
}
</script>
<style type="text/css">
body{
  color: #666;
  font-weight: bolder;
}
</style>
<title>Teste</title>
</head>
<body>
<form name="form01" id="form01" method="post" action="">
<input type="radio" name="cores" id="preto" value="black" onclick="fundo(this.value)" />
<label for="preto"> Preto</label><br />
<input type="radio" name="cores" id="branco" value="white" onclick="fundo(this.value)" />
<label for="branco"> Branco</label><br />
<input type="radio" name="cores" id="azul" value="blue" onclick="fundo(this.value)" />
<label for="azul"> Azul</label><br />
<input type="radio" name="cores" id="vermelho" value="red" onclick="fundo(this.value)" />
<label for="vermelho"> Vermelho</label><br />
<input type="radio" name="cores" id="verde" value="green" onclick="fundo(this.value)" />
<label for="verde"> Verde</label><br />
<input type="radio" name="cores" id="marrom" value="#7f421c" onclick="fundo(this.value)" />
<label for="marrom"> Marrom</label><br />
<input type="radio" name="cores" id="x" value="#404785" onclick="fundo(this.value)" />
<label for="x"> Cor X</label><br />
</form>
</body>
</html>

O visitante seleciona a cor através de radio buttons, tornando mais fácil a mudança da cor.

Link para o comentário
Compartilhar em outros sites

  • 0

outras formas:

Formulário que pode ser digitado qualquer cor (em inglês ou código hexadecimal)

<FORM>

<INPUT TYPE="text" NAME="color" SIZE=18> <INPUT TYPE="button" VALUE="Cor" ONCLICK="document.
bgColor= (this.form.color.value)"> <INPUT TYPE="reset" NAME="cancel" VALUE="Cancelar">

</FORM>
Onmouseover:

<A HREF="" ONMOUSEOVER ="document.bgColor=
'silver'">*</A> 

<A HREF="" ONMOUSEOVER ="document.bgColor=
'lightslategray'">*</A> 

<A HREF="" ONMOUSEOVER ="document.bgColor=
'azure'">*</A>

<A HREF="" ONMOUSEOVER ="document.bgColor=
'lightgreen'">*</A> 

<A HREF="" ONMOUSEOVER ="document.bgColor=
'lightblue'">*</A> 

<A HREF="" ONMOUSEOVER ="document.bgColor=
'white'">*</A>
botões (onmouseover)
<FORM>

<INPUT TYPE="button" VALUE="prata" ONMOUSEOVER="document.
bgColor='silver'">

<INPUT TYPE="button" VALUE="cinza claro" ONMOUSEOVER="document.
bgColor='lightslategray'">

<INPUT TYPE="button" VALUE="azul-branco" ONMOUSEOVER="document.
bgColor='azure'">

<INPUT TYPE="button" VALUE="verde" ONMOUSEOVER="document.
bgColor='lightgreen'">

<INPUT TYPE="button" VALUE="azul claro" ONMOUSEOVER="document.
bgColor='lightblue'">

<INPUT TYPE="button" VALUE="branco" ONMOUSEOVER="document.
bgColor='white'">

</FORM>
botões (onclick)
<FORM>

<INPUT TYPE="button" VALUE="prata" ONCLICK="document.
bgColor='silver'">

<INPUT TYPE="button" VALUE="cinza claro" ONCLICK="document.
bgColor='lightslategray'">

<INPUT TYPE="button" VALUE="azul-branco" ONCLICK="document.
bgColor='azure'">

<INPUT TYPE="button" VALUE="verde" ONCLICK="document.
bgColor='lightgreen'">

<INPUT TYPE="button" VALUE="azul" ONCLICK="document.
bgColor='lightblue'">

<INPUT TYPE="button" VALUE="branco" ONCLICK="document.
bgColor='white'">

</FORM>

Mais informações: http://www.torque.com.br/tutoriais/java_sc...undo/index.html '> http://www.torque.com.br/tutoriais/java_sc...undo/index.html

Link para o comentário
Compartilhar em outros sites

  • 0

ADEUS DÚVIDA...

aqui está:

<html>

<head>

</head>

<body>

<form name=form1>

<table border=1 align=center>

<tr><td align=center><select size=1 onchange="cor()" name=slcores >

<option value="blue">Azul</option>

<option value="red">Vermelho</option>

<option value="yellow">Amarelo</option>

<option value="green">Verde</option>

<option value="orange">Laranja</option>

</select>

</td></tr>

</table>

</form>

<script Language="JavaScript">

<!--

function cor(){

document.bgColor=(document.form1.slcores.value)

}

//-->

</script>

</body>

Link para o comentário
Compartilhar em outros sites

  • 0

Provavelmente aqui não é o lugar pra tentar sanar minhas dúvidas, mas aí vai meu código, depois coloco a dúvida.

<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table align="center" border="1" bordercolor="#000000" cellpadding="0" cellspacing="0"><tr><td>
<form name="FormTab" method="post" action="">
    <table width="300" border="0" cellspacing="0" cellpadding="0" align="center">
        <tr> 
            <td width="190"><div align="right">Quantidade de Cartelas</div></td>
            <td width="10">&nbsp;</td>
            <td width="100"><input name="<?php QtdeCart ?>" type="text" size="5"></td>
        </tr>
        <tr> 
            <td><div align="right">Qtde n&uacute;meros por cartela</div></td>
            <td>&nbsp;</td>
            <td><select name="<?php $QtdeNumCart ?>">
                <option value="6" selected>6</option>
                <option value="7">7</option>
                <option value="8">8</option>
                <option value="9">9</option>
                <option value="10">10</option>
                <option value="15">15</option>
                <option value="25">25</option>
                <option value="50">50</option>
                <option value="60">60</option>
                <option value="100">100</option>
                </select>
            </td>
        </tr>
        <tr> 
            <td><div align="right">Maior n&uacute;mero da cartela</div></td>
            <td>&nbsp;</td>
            <td><select name="<?php $MaiorNum ?>">
                <option value="59" selected>60</option>
                <option value="99">100</option>
                </select>
            </td>
        </tr>
        <tr> 
            <td colspan="3"><div align="center">
                <!-- o que coloco no onclick para fazer meus cálculos -->
                <input type="submit" name="gerar" value="Gerar cartelas" onClick="this.form;display()">
            </div>
            </td>
        </tr>
    </table>
    <br>
    <table border="1" bordercolor="#000000" cellpadding="0" cellspacing="0" align="center">
        <?php
            for ($x = 0; $x < $QtdeCart; $x++){
        ?>
        <tr> 
            <?php
                for ($y = 0; $y < $QtdeNumCart; $y++){
            ?>
            <td width="100" height="20" align="center">
                <?php
                    echo $y;
                    echo $x;
                    echo $QtdeCart;
                    echo $QtdeNumCart;
                    settype($QtdeNumCart, 'int');
                    rand (0, $QtdeNumCart);
                ?>
            </td>
            <?php } ?>
        </tr>
        <?php } ?>
    </table>
</form>
</td></tr></table>
</body>
</html>

O negócio é o seguinte, o que tenho que colocar no onclick do botão do formulário para ele fazer os meus cálculos?

Por enquanto, valeu.

Link para o comentário
Compartilhar em outros sites

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,1k
    • Posts
      651,8k
×
×
  • Criar Novo...