Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8617559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:53:22+00:00 2026-06-12T05:53:22+00:00

I have two forms that both have select/options in it (example below). My purpose

  • 0

I have two forms that both have select/options in it (example below). My purpose is so that when a user selects one of the options, the value is passed through the function and inserted into a hyperlink string. First form works fine but its when doing the second form and using the same functions that it doesn’t work, seems to clash with the first form. Is there a way to reuse this function without copy, pasting and renaming it just to work for the second as this will make the script massive?

<form>
  <select id="event_date_01" class="add_event_url">
    <option value="124167826">4th Oct 2012, 2pm-3pm AEST</option>
    <option value="398017490">4th Oct 2012, 3pm-4pm BST</option>
    <option value="536485554">25th Oct 2012, 3pm-4pm AEDT</option>
    <option value="708861114">25th Oct 2012, 3pm-4pm BST</option>
    <option value="339435154">29th Oct 2012, 3pm-4pm AEDT</option>
    <option value="915593210">29th Oct 2012, 3pm-4pm GMT</option>
  </select>
</form>
<span class="webinarLink2">
  <a href="" target="_blank" class="desturl webinarLink">
    Register now &raquo;
  </a>
</span>

<form>
 <select id="event_date_02" class="add_event_url">
  <option value="411491250">27th Sept 2012, 2pm-3pm AEST</option>
  <option value="175324970">27th Sept 2012, 3pm-4pm BST</option>
 </select> 
<span class="webinarLink2"><a href="" target="_blank" class="desturl webinarLink">Register now &raquo;</a></span>
</form>

And the javascript I am using is below

$(document).ready(function() {  
  if ($("select.add_event_url").length) {
    $("select.add_event_url").change(displayVals);
    displayVals();
  }
});

function displayVals() {
  var event_date = $("#event_date").val();
  $("a.desturl").attr('href', 'https://www2.gotomeeting.com/register/' + event_date);
}

Thanks in advance guys

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T05:53:23+00:00Added an answer on June 12, 2026 at 5:53 am

    You seem to be using select elements with identical IDs. This won’t work; IDs need to be unique.

    Give both <select>s different IDs but keep the same class, and try something like this:

    $(document).ready(function() {
        $("select.add_event_url").change(function(e) {
            var $select = $(this),
                event_date = $select.val(),
                baseurl = 'https://www2.gotomeeting.com/register/';
            $("a.desturl").attr('href', baseurl + event_date);
        });
    });​
    

    http://jsfiddle.net/74Lfg/1/

    UPDATE

    In order to traverse from your select to the correct a.desturl, you need to put them in the same relative locations so they can be traversed to from this.
    http://jsfiddle.net/74Lfg/4/

    $(document).ready(function() {
        $("select.add_event_url").change(function(e) {
            var $select = $(this),
                event_date = $select.val(),
                baseurl = 'https://www2.gotomeeting.com/register/';
            $select.closest('form').find('.webinarLink2 a.desturl').attr('href', baseurl + event_date);
        });
        $('select.add_event_url').trigger('change');
    });​
    

    HTML (note the first link has been moved inside of the form):

    <form>
      <select id="event_date_01" class="add_event_url">
        <option value="124167826">4th Oct 2012, 2pm-3pm AEST</option>
        <option value="398017490">4th Oct 2012, 3pm-4pm BST</option>
        <option value="536485554">25th Oct 2012, 3pm-4pm AEDT</option>
        <option value="708861114">25th Oct 2012, 3pm-4pm BST</option>
        <option value="339435154">29th Oct 2012, 3pm-4pm AEDT</option>
        <option value="915593210">29th Oct 2012, 3pm-4pm GMT</option>
      </select>
    <span class="webinarLink2">
      <a href="" target="_blank" class="desturl webinarLink">
        Register now &raquo;
      </a>
    </span>
    </form>
    
    <form>
     <select id="event_date_02" class="add_event_url">
      <option value="411491250">27th Sept 2012, 2pm-3pm AEST</option>
      <option value="175324970">27th Sept 2012, 3pm-4pm BST</option>
     </select> 
    <span class="webinarLink2"><a href="" target="_blank" class="desturl webinarLink">Register now &raquo;</a></span>
    </form>​
    

    Alternatively, you can assign each link a unique ID (so you can place it anywhere in the page) and add that ID as a data- attribute to the select element. http://jsfiddle.net/74Lfg/5/

    $(document).ready(function() {
        $("select.add_event_url").change(function(e) {
            var $select = $(this),
                event_date = $select.val(),
                baseurl = 'https://www2.gotomeeting.com/register/';
            $('#'+$select.data('targetlink')).attr('href', baseurl + event_date);
        });
        $('select.add_event_url').trigger('change');
    });​
    

    HTML:

    <form>
      <select id="event_date_01" class="add_event_url" data-targetlink="targetlink1">
        <option value="124167826">4th Oct 2012, 2pm-3pm AEST</option>
        <option value="398017490">4th Oct 2012, 3pm-4pm BST</option>
        <option value="536485554">25th Oct 2012, 3pm-4pm AEDT</option>
        <option value="708861114">25th Oct 2012, 3pm-4pm BST</option>
        <option value="339435154">29th Oct 2012, 3pm-4pm AEDT</option>
        <option value="915593210">29th Oct 2012, 3pm-4pm GMT</option>
      </select>
    <span class="webinarLink2">
      <a href="" target="_blank" id="targetlink1" class="desturl webinarLink">
        Register now &raquo;
      </a>
    </span>
    </form>
    
    <form>
     <select id="event_date_02" class="add_event_url" data-targetlink="targetlink2">
      <option value="411491250">27th Sept 2012, 2pm-3pm AEST</option>
      <option value="175324970">27th Sept 2012, 3pm-4pm BST</option>
     </select> 
    <span class="webinarLink2"><a href="" target="_blank" class="desturl webinarLink" id="targetlink2">Register now &raquo;</a></span>
    </form>​​​​​​​​​​​​​​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two forms, one with a radio button that users must select to
I (currently) have two forms, one that needs to call the other. In other
I have encountered a problem in my application. I have two forms, one that
I have an application that consists of two forms. One form displays data returned
I have an xml that comes in two forms <root> <element1 req=mandatory/> <element2/> <element3/>
I have Process objects that are monitored from two different views. A Windows.Forms.ListView (actually
I have a form that has two buttons on it, one yes, one no,
I have two rating/votes tables. One for user votes and stats and another for
I have a simple PHP script with a form that has two select fields,
I have two web forms which are filled in by the user. They contain

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.