Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jul 2008
    Posts
    13
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Exclamation Page result after submitting form opening in new window

    Hi,

    I am using Javascript to display options in a form with 2 dropdown lists. However, despite using the target='_self', the result opens in a new window. Help would be much appreciated.

    Code:
    // JavaScript Document
    function setOptions(chosen) {
    var selbox = document.ChronoContact_course_finder.opttwo;
     
    selbox.options.length = 0;
    if (chosen == ' ') {
      selbox.options[selbox.options.length] = new Option('Choose Option',' ');
     
    }
    if (chosen == '85') {
      selbox.options[selbox.options.length] = new Option('ITEC Beauty Specialist Diploma','index.php?option=com_content&view=article&id=49&Itemid=68',target='_self');
      selbox.options[selbox.options.length] = new Option('ITEC Professional Makeup','index.php?option=com_content&view=article&id=57&Itemid=76',target='_self');
      selbox.options[selbox.options.length] = new Option('Fashion Catwalk & Photographic Makeup Course','index.php?option=com_content&view=article&id=67&Itemid=91',target='_self');
      selbox.options[selbox.options.length] = new Option('Bridal Makeup Course','index.php?option=com_content&view=article&id=68&Itemid=92',target='_self');
      selbox.options[selbox.options.length] = new Option('Special Effects Makeup','index.php?option=com_content&view=article&id=56&Itemid=77',target='_self');
      selbox.options[selbox.options.length] = new Option('Gel Nails Course','index.php?option=com_content&view=article&id=65&Itemid=88',target='_self');
      selbox.options[selbox.options.length] = new Option('Acrylic Nails Course','index.php?option=com_content&view=article&id=66&Itemid=89',target='_self');
      selbox.options[selbox.options.length] = new Option('Spray Tanning Course','index.php?option=com_content&view=article&id=55&Itemid=73',target='_self');  
    }
    if (chosen == '69') {
      selbox.options[selbox.options.length] = new Option('ITEC Holistic Massage Course','index.php?option=com_content&view=article&id=51&Itemid=2',target='_self');
      selbox.options[selbox.options.length] = new Option('ITEC Sports Massage Diploma','index.php?option=com_content&view=article&id=59&Itemid=78',target='_self');
      selbox.options[selbox.options.length] = new Option('Indian Head Massage Course','index.php?option=com_content&view=article&id=60&Itemid=79',target='_self');
      selbox.options[selbox.options.length] = new Option('ITEC Reflexology Diploma','index.php?option=com_content&view=article&id=64&Itemid=87',target='_self');
    }
    if (chosen == '80') {
      selbox.options[selbox.options.length] = new Option('ITEC Teaching Diploma','index.php?option=com_content&view=article&id=61&Itemid=81',target='_self');
      selbox.options[selbox.options.length] = new Option('FETAC Train The Trainer Level 6','index.php?option=com_content&view=article&id=63&Itemid=86',target='_self');
    }
    if (chosen == '83') {
      selbox.options[selbox.options.length] = new Option('ITEC Sports Massage Diploma','index.php?option=com_content&view=article&id=59&Itemid=90',target='_self');
    
    }
    }
    And the HTML...

    Code:
    <div class="form_item">
      <div class="form_element cf_heading">
        <h1 class="cf_text">course finder</h1>
      </div>
      <div class="cfclear">&nbsp;</div>
    </div>
    
    <div class="form_item">
      <div class="form_element cf_dropdown">
        <label class="cf_label" style="width: 200px;">Step 1: Choose type of course</label>
        <select name="optone" class="cf_inputbox" size="1" onchange="setOptions(document.ChronoContact_course_finder.optone.options[document.ChronoContact_course_finder.optone.selectedIndex].value);">
          <option value=" " selected="selected">Choose Option</option>
          <option value="85">Beauty courses</option>
    	  <option value="69">Complimentary courses</option>
    	  <option value="80">Teaching courses</option>
    	  <option value="83">Fitness courses</option>	  
    
        </select>
        
      </div>
      <div class="cfclear">&nbsp;</div>
    </div>
    
    <div class="form_item">
      <div class="form_element cf_dropdown">
        <label class="cf_label" style="width: 200px;">Step 2: Choose a subject</label>
        <select size="1" name="opttwo" class="cf_inputbox" >
        <option value=" " selected="selected">Choose Option</option>
          
        </select>
        <!--<input type="button" name="go" value="Value Selected" onclick="window.open(document.ChronoContact_course_finder.opttwo.options[document.ChronoContact_course_finder.opttwo.selectedIndex].value);">-->
      </div>
      <div class="cfclear">&nbsp;</div>
    </div>
    
    <div class="form_item">
      <div class="form_element cf_button">
        <input type="submit" name="go" value="search" onclick="window.open(document.ChronoContact_course_finder.opttwo.options[document.ChronoContact_course_finder.opttwo.selectedIndex].value);">
      </div>
      <div class="cfclear">&nbsp;</div>
        
    </div>
    Many thanks,
    Paul
    Last edited by onoffpaul; 12-13-2010 at 12:41 AM. Reason: Forgot to add in HTML code

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,650
    Thanks
    80
    Thanked 4,638 Times in 4,600 Posts
    You can't add a target to an <option>!!!

    You can only add a target to a <form> or <a> or <area> tag.

    You can also *specify* a target in window.open(), but that's certainly got nothing (directly) to do with the <option>.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    New Coder
    Join Date
    Jul 2008
    Posts
    13
    Thanks
    2
    Thanked 0 Times in 0 Posts
    This is a form within Joomla so I'm not able to edit the form tag. Is there an alternative way to target the same window?

    Many thanks,
    Paul


  •  

    Tags for this Thread

    Posting Permissions

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