This is a discussion on "newbie javascript problem" within the JavaScript Forum section. This forum, and the thread "newbie javascript problem are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
newbie javascript problem
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
newbie javascript problem
I have been asked to alter some navigation element links on a site that will steer users to relevant content depending on which country they select in a select menu. I would like to use javascript to do this but i'm not sure the way to go about it.
This is an example of markup I have to work with:
I was thinking to use an onSelect event in each option tag to set/change the value of the variable that would be somehow called at the end of the link url in the li Any ideas on how to do this? |
|
|
|
||||
|
Re: newbie javascript problem
Okay, this would be pretty simple I believe
if you add id="s_coco" to the select tag and id="links_list" to ul tag. the at some point after the </ul> add
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
Last edited by Rakuli; Sep 6th, 2007 at 13:06. |
|
|||
|
Re: newbie javascript problem
Thanks for the help Rakuli,
It does not seem to be working for me though in that the end of the link does not change on the fly. Maybe i'm missing something:
|
|
||||
|
Re: newbie javascript problem
Sorry mate
I misspelt javascript ... lmao
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
|
|
|||
|
Re: newbie javascript problem
Ooh, I hadn't caught that... Now corrected but I still cannot get it to work...
|
|
||||
|
Re: newbie javascript problem
That exact script above (directly above your post) works for me in FF and IE.
Are you adding anything else to it?
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
|
|
|||
|
Re: newbie javascript problem
Quote:
So instead of: href="http://www.mysite.com/search/category1/all" the link would change to: href="http://www.mysite.com/search/category1/uk" or: href="http://www.mysite.com/search/category1/us" ? |
|
|||
|
Sorry, I repasted the amended code you corrected to my html and it works now..
Many thanks for your help! |
|
|||
|
Re: newbie javascript problem
Actually I had another idea. I think for my purposes rather than the javascript counting the number of '/' and adding/appending the variable to the end of the link, would it be difficult to have it look for a string or something in the url and replacing it? The reason I ask is the url I gave in the example will most definately not always be the same length or path so this javascript just breaks the link if its not always the same length as the example...
|
|
||||
|
Re: newbie javascript problem
What that script is actually doing is finding the very last '/' and removing what is after it replacing it with the country code. So if there will always be a /language it will always work.
Cheers
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
|
|
|||
|
Re: newbie javascript problem
Quote:
|
![]() |
| Tags |
| events, javascript, variables |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Newbie to Javascript | dapirates | JavaScript Forum | 5 | Mar 11th, 2008 21:21 |
| Javascript newbie | sehrlund | JavaScript Forum | 6 | Aug 23rd, 2007 18:07 |
| Newbie, Please help with javascript links | lea | JavaScript Forum | 1 | Nov 9th, 2006 14:45 |
| Newbie in Javascript | ktsirig | JavaScript Forum | 1 | Mar 12th, 2006 05:20 |
| JavaScript Newbie Seeks Guidance | jswebdev | JavaScript Forum | 0 | Dec 5th, 2005 20:44 |