Geeks With Blogs

News
About Me:
I am a Female SharePoint Developer (a platinum unicorn). I have been working with SharePoint since I attended the Portal University in 2005. I hold a BA in Computer Science from the University of Missouri - Kansas City. I love playing Rockband, organizing user group meetings, working with code, attending events as a speaker or organizer, and having bizarre conversations about geek things with cool people. If you have any comments or questions fill out the contact form and I will try my best to help.



The Guide of a MOSSLover Becky Isserman's Blog
I was working on a search hack and needed the session state from ASP .Net controls and the ids from html controls using this hack: http://www.tqcblog.com/archive/2007/10/26/creating-a-custom-advanced-search-box-in-moss-2007.aspx.  So I came up with a creative solution.  I would add the html controls in the background.  Here is some code if you would like to add your own hidden html controls or just create some for fun:

var currentElement = document.createElement("input");

currentElement.setAttribute("type", "hidden");
currentElement.setAttribute("name", "YourName");
currentElement.setAttribute("id", "YourID");
currentElement.setAttribute("value", "YourValue");
document.getElementById("DivName").appendChild(currentElement);

You are going to want to create a div or a span to add your elements or you can do document.body.appendChild.  SharePoint for some reason did not like that statement, so I created a div before the button to add the elements.  You do not need to add a hidden element.  You can add a checkbox, but remember to add an element.display = "none"; or it will display the item.  If you have any comments or questions send them my way.  Hope you all have a good week! Posted on Wednesday, August 13, 2008 4:14 PM MOSS , Javascript | Back to top


Comments on this post: Creating Dynamic Controls with Javascript

# re: Creating Dynamic Controls with Javascript
Requesting Gravatar...
Quite Simple way of description. Was really worthful.
Left by Abhay Kr. Pandey on May 15, 2009 1:46 AM

# re: Creating Dynamic Controls with Javascript
Requesting Gravatar...
if division is not needed then how would the code been??
Left by priya on Jun 10, 2010 3:59 AM

Your comment:
 (will show your gravatar)


Copyright © MOSSLover | Powered by: GeeksWithBlogs.net