Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2014
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. <input type="radio" id="id1" onclick="change()">Radio Button</input>
  2.  
  3. <a href="page3.html" id="id2">Link</a>
  4.  
  5. function change()
  6. {
  7. if(document.getElementById(id1).checked)
  8. {
  9. document.getElementById(id2).href="page4.html";
  10. }
  11. }
  12.  
  13. <script src="js_file.js" type="text/javascript" />
  14.  
  15. <input type="radio" name="radio1" id="radio1" onclick="change.js">Radio Button</input>
  16.  
  17. <input type="hidden" name="radio1" value="XXX">
  18.  
  19. <!DOCTYPE html>
  20. <html>
  21. <head>
  22. <script>
  23. window.addEventListener('load', onDocLoaded, false);
  24.  
  25. function onDocLoaded()
  26. {
  27. var urlRadios = document.getElementsByName('urlSelector');
  28. var i, n = urlRadios.length;
  29. for (i=0; i<n; i++)
  30. urlRadios[i].addEventListener('click', onUrlRadioChange, false);
  31. }
  32.  
  33. function onUrlRadioChange(evt)
  34. {
  35.  
  36. localStorage.destUrl = this.getAttribute('dest');
  37. localStorage.destTxt = this.getAttribute('msg');
  38. }
  39.  
  40. </script>
  41. <style>
  42. </style>
  43. </head>
  44. <body>
  45. <h3>Pick destination of link on page 2</h3>
  46. <input type='radio' msg='No page selected' dest='none' checked name='urlSelector'>none</input>
  47. <input type='radio' msg='Page 3' dest='page3.html' name='urlSelector'>page3.html</input>
  48. <input type='radio' msg='Page 4' dest='page4.html' name='urlSelector'>page4.html</input>
  49. <hr>
  50. <a href='page2.html'>Page 2</a>
  51. </body>
  52. </html>
  53.  
  54. <!DOCTYPE html>
  55. <html>
  56. <head>
  57. <script>
  58. function byId(e){return document.getElementById(e);}
  59. window.addEventListener('load', onDocLoaded, false);
  60.  
  61. function onDocLoaded()
  62. {
  63. if (localStorage.destUrl != 'none')
  64. byId('tgtLink').href = localStorage.destUrl;
  65. byId('tgtLink').innerHTML = localStorage.destTxt;
  66. }
  67. </script>
  68. <style>
  69. </style>
  70. </head>
  71. <body>
  72. <h3>Destination was set by page 1</h3>
  73. <a id='tgtLink'>Link</a>
  74. </body>
  75. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement