Monday, April 7, 2008

Dropdown with URL in onchange

If you want to create a dropdown list with onchange event to dynamically go to selected URL then do this:

Use Sharepoint Designer
Insert Data View
Select Show Data
Select which field that should be displayed in the drop-down list
Insert Data
ViewData..
Style
Change layout to “Drop-down view style”
Click OK
Change to Code view in Designer
Put the following code before the /head> tag:

script language="JavaScript">

/script>

Then find the following in your code
select name="ID" size="1"12
Change that to
select name="ID" size="1" onchange="FP_jumpMenu(this,'window',false)">

Then find
option style="display:{$GroupStyle}"
Change to
option style="display:{$GroupStyle}" value=”{@FieldWithURL}”>
where FieldWithURL is the link that you want to go to
Save

2 comments:

jea said...

I haven't had any luck with associating your code with a typical sharepoint designer dropdown list. Can you provide the actual design view code?

Thanks,
Jim.e.althoff@ssa.govpredicar

Lise said...

Hi!
Could you please supply your code and I will have a look?
It was a long time ago I tried that out, and dont think I have my old default.aspx page left. But I'll have a look at yours if you like.
Take care,
/Lise