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

Checkbox E Radiobutton


lkm

Pergunta

6 respostass a esta questão

Posts Recomendados

  • 0

eu também não, por isso ainda não decorei a sintaxe de for...

<script>

if(form.myCheckBox.checked==true){

i = 0;

while(i<document.form.radios.legth){

document.form.radios.disabled=false;

i = i+1;

}

} else

{

i = 0;

while(i<document.form.radios.legth){

document.form.radios.disabled=true;

i = i+1;

}

}

</script>

<form name="form">

<input type="checkbox" name="myCheckBox" id="myCheckBox" value="meuvalor">

<input type="radiobutton" name="radios" id="radios" value="meuvalor" disabled=true>

<input type="radiobutton" name="radios" id="radios" value="meuvalor" disabled=true>

<input type="radiobutton" name="radios" id="radios" value="meuvalor" disabled=true>

</form>

acabei de escrever, não sei se funciona.... só pra você ter uma ideia de como pode-se fazer esse tipo de coisa...

ok?

falows!

Link para o comentário
Compartilhar em outros sites

  • 0
Guest Visitante

não funcionou, mas eu achei um código parecido com o que eu quero:

<html>

<head>

<script>

var checkobj

function agreesubmit(el){

checkobj=el

if (document.all||document.getElementById){

for (i=0;i<checkobj.form.length;i++){ //hunt down submit button

var tempobj=checkobj.form.elements

if(tempobj.type.toLowerCase()=="submit")

tempobj.disabled=!checkobj.checked

}

}

}

function defaultagree(el){

if (!document.all&&!document.getElementById){

if (window.checkobj&&checkobj.checked)

return true

else{

alert("Please read/accept terms to submit form")

return false

}

}

}

</script>

</head>

<body>

<form name="agreeform" onSubmit="return defaultagree(this)">

Rest of your form here<br>

<input name="agreecheck" type="checkbox" onClick="agreesubmit(this)"><b>I agree to the above terms</b><br>

<input type="Submit" value="Submit!" disabled>

</form>

<script>

document.forms.agreeform.agreecheck.checked=false

</script>

<p align="center"><font face="Arial" size="-2">Free DHTML scripts provided by<br>

<a href="http://www.dynamicdrive.com">Dynamic Drive</a></font></p>

</body>

</html>

porém em vez de habilitar um botão eu preciso que ele habilite um radiobutton

Link para o comentário
Compartilhar em outros sites

  • 0

no seu código pogoball não aconteceu nada, não sei porque não funcionou, mas acabei adaptando o código que eu havia postado anteriormente e ficou assim (funcionando do jeito que eu precisava) se alguém precisar está aqui:

<html>

<head>

<script>

var checkobj

function agreesubmit(el){

checkobj=el

if (document.all||document.getElementById){

for (i=0;i<checkobj.form.length;i++){ //hunt down submit button

var tempobj=checkobj.form.elements

if(tempobj.name.toLowerCase()=="opcao")

tempobj.disabled=!checkobj.checked

}

}

}

function defaultagree(el){

if (!document.all&&!document.getElementById){

if (window.checkobj&&checkobj.checked)

return true

else{

alert("Please read/accept terms to submit form")

return false

}

}

}

</script>

</head>

<body>

<form name="agreeform" onSubmit="return defaultagree(this)">

<p>Rest of your form here<br><input name="agreecheck" type="checkbox" onClick="agreesubmit(this)">

<b>I agree to the above terms</b><br><input type="Submit" value="Submit!" disabled>

</p>

<table width="200">

<tr>

<tudo><label><input type="radio" name="opcao" value="rádio" disabled>Rádio</label></tudo>

</tr>

<tr>

<tudo><label><input type="radio" name="opcao" value="rádio" disabled>Rádio</label></tudo>

</tr>

<tr>

<tudo><label><input type="radio" name="opcao" value="rádio" disabled>Rádio</label></tudo>

</tr>

</table>

</form>

<script>

document.forms.agreeform.agreecheck.checked=false

</script>

<p align="center"><font face="Arial" size="-2">Free DHTML scripts provided by<br>

<a href="http://www.dynamicdrive.com">Dynamic Drive</a></font></p>

</body>

</html>

mas obrigado pela ajuda pogoball, valeu e t+

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...