Hi everybody

I am trying to develop an application, in which i want your help and suggestions.

I have a master page and many content pages. I want to write a javascript function in the master page script, and call that function in body onload.

I have a field in User table, which has the CSS files choosen by that user. The field value is just the file name, but not with extension .css
I have a stored procedure which retuns this CSS field values, if supplied userid.

The problem is that, I am not getting an idea how to write the function, which executes the stored procedure, taking userid as parameter, and then get the returned value, adding a .css extension to that, and assiging that field value.css to the href of the link?

Can anyone please help me in this?


From what you say, it sounds like your stored proceedure is a server side script that returns some stored information about a user's preferences when the user logs in. If this is so I would advise the following. Get the stored proceedure to serve a page with a script in it that sets a cookie:

<script type="text/javascript">document.cookie='user_info=my_style_sheet;
expires=Fri, 26 Jan 2007 21:08:00; path=http://your_domain.com';
setTimeout("set_link()", 2000)</script>

You can find info about how to correctly set a cookie here. So, the server side script generates the correct javascript code to set a cookie when that code is run on the client machine. Then, make your javascript app. read the cookie and set the link based on this:

<script type="text/javascript">
function set_link() {
var cookie = document.readCookie('user_info');
var crumbs = cookie.split(=);
var style = crumbs[1];
var file_name = style + ".css";
document.write("<a href=\"file_name\">Your style</a>");

A couple of things to note here:

1. This is a rough sketch of what you might need to do. I'm not an expert so there might be mistakes in there.

2. Remember that your server side script will need to generate the correct javascript code to set the cookie in the first place, or this won't work.

Hope this gives you some ideas.