SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: radio button

  1. #1
    SitePoint Addict
    Join Date
    Jun 2008
    Posts
    205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    radio button

    How to open the page in another window when radio button value 4 is selected. When other option is selected open in same window.

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,526
    Mentioned
    83 Post(s)
    Tagged
    4 Thread(s)
    Code html4strict:
    <form id="myForm">
    	<p>Window in which to open the link?
    		<label><input type="radio" name="openMethod" value="this">This</input>
    	    <label><input type="radio" name="openMethod" value="same">Same</input>
    	    <label><input type="radio" name="openMethod" value="current">Current</input>
    	    <label><input type="radio" name="openMethod" value="other">New</input>
    	</p>
    </form>
    <p><a id="specialLink" href="somewhere.html">Link to somewhere</a></p>

    Code javascript:
    link = document.getElementById('specialLink');
    link.onclick = function () {
    	myForm = document.getElementById('myForm');
    	if (myForm.elements.openMethod[3].checked === true) {
    		window.open(this.href, 'specialWindow', 'width=500,height=300,top=100,left=200');
    		return false;
    	}	
    }
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Addict
    Join Date
    Jun 2008
    Posts
    205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by pmw57 View Post
    Code html4strict:
    <form id="myForm">
    	<p>Window in which to open the link?
    		<label><input type="radio" name="openMethod" value="this">This</input>
    	    <label><input type="radio" name="openMethod" value="same">Same</input>
    	    <label><input type="radio" name="openMethod" value="current">Current</input>
    	    <label><input type="radio" name="openMethod" value="other">New</input>
    	</p>
    </form>
    <p><a id="specialLink" href="somewhere.html">Link to somewhere</a></p>

    Code javascript:
    link = document.getElementById('specialLink');
    link.onclick = function () {
    	myForm = document.getElementById('myForm');
    	if (myForm.elements.openMethod[3].checked === true) {
    		window.open(this.href, 'specialWindow', 'width=500,height=300,top=100,left=200');
    		return false;
    	}	
    }
    Thanks for the reply. But I am using submit button.

    If i use submit button instead of <a href> I am not able to open the option 4 of radio button in another page.


    Please help me

  4. #4
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,526
    Mentioned
    83 Post(s)
    Tagged
    4 Thread(s)
    Are you wanting to show the results of the submitted form in a popup window?
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •