Using Javascript to search a share point list

Jul 16, 2010 03:30

I found this code a while ago that creates a drop down search box that will search a sharepoint list. I am extremely new to this so I am clueless in how I can modify this code to suit my needs. The code redirects to the same page with querystring data added to the URL. I was able to modify the drop down list and I changed the Column names to ( Read more... )

Leave a comment

Comments 5

digitalsidhe July 16 2010, 17:02:50 UTC
The problem is that elements don't have a value attribute of their own. Instead, they have an array called options that contains all the 's elements (each of which has a value of its own), and a selectedIndex attribute that says which of those options is the selected one. So instead of:

var cs = document.getElementById("sfield").value;

, you need to say something like:

var sfield = document.getElementById("sfield");
var cs = sfield.options[sfield.selectedIndex].value;

Yeah, it's a bit unwieldy. (This is one of the reasons most JavaScript coders like to use frameworks. But I'd never discourage someone from learning to deal with raw JS first, just so they understand what's really going on!)

Reply

immortalsofar July 19 2010, 03:25:47 UTC
I've never had a problem with select.value myself. Never used a framework, either - they never do things the way I want them to.

Reply

sweetsdecline July 19 2010, 08:41:54 UTC
Thanks for your help!! I switch the code but it still isnt working. I think I am over my head with this.

Reply


immortalsofar July 19 2010, 03:36:31 UTC
The critical reason for Column 5/6 is in the asp file - for some reason, the original code expects input in a different format for date-entered or DOB.

If you want to simplify it, just stick the damned thing into a form and submit it. There's no need to redirect the page anyway.

Reply

sweetsdecline July 19 2010, 08:46:41 UTC
Thanks for the explanation on the column5/6!! That makes sense as they are both dates!!

I think I am really over my head with this. I thought I could magically fix the code to fit my needs but its way too complicated. With sharepoint you can only have one text filter on a page and this was something I though would help me filter more than one column on a page.

Reply


Leave a comment

Up