Hello Guys,

 

I'm looking for some help on getting started with a script that'll change
the href attribute of a link dependant on the option selected in a select
box. To add a little 'spice' the challenge the value of the href must be
determined from a set of key value pairs. Let me try and offer an example.

 

I have a select box like this:

 

      <select name="customer" id="customer">

            <option value="1">Joe Bloggs</option>

            <option value="2">Dave Something</option>

      </select>

 

And the link which I want to change dependant on the selection looks
something like this:

 

      <a href="/view_customer_company.cfm?company_id=6">View Customers
Company</a>

 

I've highlighted the bits in red which I wish to make dynamic dependant on
the option chosen in the select box. Where I've put 'customers' I want to
dynamically change to the option text, such as 'Joe Bloggs' or 'Dave
Something' and the company_id value I need to pull from a key/value set
using the option value as the key, such as 1 or 2. The key/value pairs look
something like this:

 

Key:value

1: 50ccdae0-79bf-11dd-ad8b-0800200c9a66

2: 9c335820-d878-4db3-b90a-728046cb8849

 

So, as a quick summation of the expected results, If I select 'Joe Bloggs'
in my select list, I want the link to be changed to:

 

      <a
href="/view_customer_company.cfm?company_id=50ccdae0-79bf-11dd-ad8b-0800200c
9a66">View Joe Bloggs Company</a>

 

And likewise, if I chose 'Dave Something' in the select list the link would
look like this:

 

      <a
href="/view_customer_company.cfm?company_id=9c335820-d878-4db3-b90a-728046cb
8849">View Dave Something Company</a>

 

I'm really a novice with both JavaScript and jQuery for the moment, I'm
learning well but this is a little bit beyond me, especially when you're
looking at working with the key/value paris.

 

I appreciate any help you can offer and thanks in advance for your time.

 

Robert

Reply via email to