Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <input type="radio" id="id1" onclick="change()">Radio Button</input>
- <a href="page3.html" id="id2">Link</a>
- function change()
- {
- if(document.getElementById(id1).checked)
- {
- document.getElementById(id2).href="page4.html";
- }
- }
- <script src="js_file.js" type="text/javascript" />
- <input type="radio" name="radio1" id="radio1" onclick="change.js">Radio Button</input>
- <input type="hidden" name="radio1" value="XXX">
- <!DOCTYPE html>
- <html>
- <head>
- <script>
- window.addEventListener('load', onDocLoaded, false);
- function onDocLoaded()
- {
- var urlRadios = document.getElementsByName('urlSelector');
- var i, n = urlRadios.length;
- for (i=0; i<n; i++)
- urlRadios[i].addEventListener('click', onUrlRadioChange, false);
- }
- function onUrlRadioChange(evt)
- {
- localStorage.destUrl = this.getAttribute('dest');
- localStorage.destTxt = this.getAttribute('msg');
- }
- </script>
- <style>
- </style>
- </head>
- <body>
- <h3>Pick destination of link on page 2</h3>
- <input type='radio' msg='No page selected' dest='none' checked name='urlSelector'>none</input>
- <input type='radio' msg='Page 3' dest='page3.html' name='urlSelector'>page3.html</input>
- <input type='radio' msg='Page 4' dest='page4.html' name='urlSelector'>page4.html</input>
- <hr>
- <a href='page2.html'>Page 2</a>
- </body>
- </html>
- <!DOCTYPE html>
- <html>
- <head>
- <script>
- function byId(e){return document.getElementById(e);}
- window.addEventListener('load', onDocLoaded, false);
- function onDocLoaded()
- {
- if (localStorage.destUrl != 'none')
- byId('tgtLink').href = localStorage.destUrl;
- byId('tgtLink').innerHTML = localStorage.destTxt;
- }
- </script>
- <style>
- </style>
- </head>
- <body>
- <h3>Destination was set by page 1</h3>
- <a id='tgtLink'>Link</a>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement