[jQuery] Re: Change link dependant on select box.
Morningz, That's exactly what it was, I took out the pound sign and it work perfectly! Thanks mate, I appreciate the help. Robert -Original Message- From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of MorningZ Sent: 04 September 2008 13:18 To: jQuery (English) Subject: [jQuery] Re: Change link dependant on select box. that example above was totally off the top of my head to try to point you the way i do quickly see one issue with it though var obj = document.getElementById("#customer"); should not have the "#" sign var obj = document.getElementById("customer");
[jQuery] Re: Change link dependant on select box.
that example above was totally off the top of my head to try to point you the way i do quickly see one issue with it though var obj = document.getElementById("#customer"); should not have the "#" sign var obj = document.getElementById("customer");
[jQuery] Re: Change link dependant on select box.
Morning Morningz, > Why wouldn't you just have > > > Joe > Bloggs > Dave > Something > > > > > > > $(document).ready(function() { > $("#customer").change(SetLink); > SetLink(); > }); > function SetLink() { >var obj = document.getElementById("#customer"); >obj = obj.options[obj.selectedIndex]; >$("#CompanyLink") > .attr("href", '/view_customer_company.cfm?company_id=' > + obj.value) > .html('View ' + obj.text + ' Company'); > } > > > deeming the key/value lookup unnecessary? The reason I can't do this is because the 9c335820-d878-4db3-b90a-728046cb8849 isn't the ID of the customer which is ultimately what I need when I submit the form, so this has to stay as the numeric ID value. The link which changes is just a usability thing to allow my users to quickly check the background of the customer before they submit the form, but to check the background I need their company_id, which is why we need the key:value pair. Is the key:value pair complicated to implement into your above example? I understand the code you've provided but wouldn't really know where to start enhancing it. Thanks for your advice mate, I appreciate it. Robert
[jQuery] Re: Change link dependant on select box.
Morningz, As another little note, I was testing your example code this morning but I get an 'Object Required' error thrown by it, any ideas what might be causing this? I definitely have the HTML elements with the correct ID's present on the page, any other thoughts? Don't worry about the key:value pair side of things as I can probably solve that little challenge with some Server Side scripting which will be more robust. If we can get the error resolved the example you've given should give me exactly what I need :-) Thanks, Robert
[jQuery] Re: Change link dependant on select box.
Why wouldn't you just have Joe Bloggs Dave Something $(document).ready(function() { $("#customer").change(SetLink); SetLink(); }); function SetLink() { var obj = document.getElementById("#customer"); obj = obj.options[obj.selectedIndex]; $("#CompanyLink") .attr("href", '/view_customer_company.cfm?company_id=' + obj.value) .html('View ' + obj.text + ' Company'); } deeming the key/value lookup unnecessary?