Jump to content

newprogrammingfan

New Members
  • Posts

    5
  • Joined

  • Last visited

Everything posted by newprogrammingfan

  1. I am new at javascript,and i was trying and trying with this but something is wrong,i wanna make the checked radio button red and green if not checked,or black no matter,the essence is to make red the selected radio button,so if i select one it becomes red,this is what i know how to do but when i select another,make the radio button which i selected and became red,change it back to black,or green...i was trying with green to see better if anything works cuz the defaulth is black.So here is the code that does't works yet. szc.php <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script type="text/javascript" src="query.js"></script> <style> .p1:hover { cursor:pointer; } </style> </head> <body> <form action="szc.php" method="post"> <label class="p1"><input type="radio" class="p1" name="rg" id="id1" value="anything1"><font id="L1">This?</font></label> <label class="p1"><input type="radio" class="p1" name="rg" id="id2" value="anything2"><font id="L2">Or this?</font></label> <input type="submit"/></form> </body> </html> query.js <script type="text/javascript"> window.onload = function(){ var id1 = document.getElementById("id1"); id1.onclick = function(){ if( id1.checked == true) { id1.style.color = "rgb(255, 0, 0)"; } if ( id1.checked == false) { id1.style.color = "rgb(0, 255, 0)"; } } var id2 = document.getElementById("id2"); id2.onclick = function(){ if( id2.checked == true) { L2.style.color = "rgb(255, 0, 0)"; } else { L2.style.color = "rgb(0, 255, 0)"; } } }; </script> Any help welcome!
  2. I tryed with button,but still no succes,some help to a beginner please? <!DOCTYPE html> <html> <head> <script> document.getElementById('change').onclick = changeColor; function changeColor() { if(document.getElementById('color').style.color == "black";) { document.getElementById('color').style.color = "blue"; } else { document.getElementById('color').style.color = "black"; } } </script> </head> <body> <script type="text/javascript"> document.getElementById('color').style.color="black"; </script> <button onclick="changeColor">Color Change</button> <p id="color">Hey there!</p> </body> </html>
  3. Thanks!But it won't change the color back so i made a modification,but still not works,can anyone help with it? Files and their contents are below-> textcolor.php: <html> <head> <script src="jquerry.js"></script> </head> <body> <span id="colorChange">Clicking this text changes the color of it.</span> </body> </html> jquerry.js: window.onload = function(){ var cc = document.getElementById("colorChange"); var dd = document.getElementById("colorChange"); if( !cc ) cc.onclick = function(){ if( cc.style.color == "rgb(255,0,0)" ) cc.style.color = "rgb(0,0,0)"; }; if( !dd ) dd.onclick = function(){ if( cc.style.color = "rgb(0,0,0)" ) dd.style.color = "rgb(255,0,0)"; }; };
  4. Hi! I am new at this,so can anyone show or tell me how can i make a text that changes color all the time when i click on it.When first time i click on the black text -> it changes to Red,when i click again it become black again and if i click again it becomes Red and so on,This in a circle.How can i do this? Thanks for the help and please no flaming i am new yet,and didn't found my answer on the net yet... Any help or idea welcome!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.