Talk:SimpleForms categorisation example

From Organic Design

Missing something?

I get

*Select category{{#dpl: namespace = Category | mode = userformat | listseparators = ,\n*%TITLE%,, }}

in the dropdown list instead of the categories. Am I missing another extension? If so, what is it? Thanks, --Paulhat 07:52, 7 July 2007 (NZST)

I found my problem. I had an old version of DPL. They've been busy. --Paulhat 08:07, 7 July 2007 (NZST)

Yeah they're almost coming out with a new version every week! --Nad 10:03, 7 July 2007 (NZST)

Recent categories take a while to appear in the list

I've been using something like this on my test wiki. When a new category is added it takes a few pages refreshes for it to appear in the category list. Perhaps there is some caching going on. I've got the simpleform in a template that I use in the wikiskin article. --Rob 12:38, 10 October 2007 (NZDT)

If its a big wiki it may be because the catlinks are getting updated in a job queue - I thought this only happened when over 100000 needed to be updated though... --Nad 12:44, 10 October 2007 (NZDT)

Category does not get added

When I use this example, the category does not get added. Instead, it just adds [[Category:]] even though I selected an actual category. This happens for me when I am categorizing the current page, an existing page with no existing categories, an existing page with existing categories, or a new page. Looking at your example page, it appears this is also happening. Do you have any ideas about what I might be doing wrong? Also, can you provide a referenec where I might be able to read about what is happening in the onChange part of the code? I understand the DPL query and the rest of the simple forms code, but I do not know what is going on in the onChange part of the code. Thanks --Matt

I suspect it is a browser specific javascript issue, what browser? It just worked for me --Sven 23:06, 11 January 2008 (NZDT)

You are right. I tried it in Netscape and it worked perfectly. However, it does not work on IE6 or IE7. Any suggestions about how I can get it to work with IE?

Thanks --Matt

We need to identify what Javascript differences are causing the AJAX requests to fail depending on the browser. The new Extension:Selenium.php might be useful here for creating automated browser specific tests where a certain output is expected -See Special:Selenium --Sven 09:40, 13 January 2008 (NZDT)
It's not a complete solution but here is a code fragment I have used to do XHR requests. I've tested it on all the major browsers and it works. Unusually the one I had the most trouble with was Safari < 3. It has a number of reserved words that other javascript engines have no problems with. For example, if you use a variable called long it throws an error because long is used as a data type.
var xhr = window.XMLHttpRequest;

function ajax(url, vars, object) {
		if (xhr)
		  var http = new XMLHttpRequest();
		  var http = new ActiveXObject("MSXML2.XMLHTTP.3.0");
"POST", url, true);
        http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 

        http.onreadystatechange = function(){

                if (http.readyState == 4 && http.status == 200) {

                        if (http.responseText){
                                object.innerHTML = http.responseText;

The working example can be seen on this page. See the People search box on the right. --Rob 10:26, 13 January 2008 (NZDT)

I don't think it can be the XHR itself, because I'm just using MW's native AJAX calls these days (and even before that was using either Mootools or W3C XHR code, so I don't think that's ever been an issue), it must be some of the other JS in the forms that's wrong. --Nad 11:06, 13 January 2008 (NZDT)

Here is the code I am using.

{{#input:type=hidden|name=summary|value=Article category updated/created from form}}

Name of new page: {{#input:type=input|name=title|value=Page Title}}
Category for new page: {{#input:type= select|*Select a page category
{{#input:type=submit|value=Create Page}}

Unfortunately, I am not a programmer and I am not familiar with javascript (although the link to the javascript primer on Sven's user site is very helpful). Is there somewhere I might be able to read about some of the common javascript problems with internet explorer?

Also, I am trying to create a second drop-down select box based on what the input for the first select field is. For example, if the user selects to create a page in category a, I would like them to be able to then select from all categories within category a and so on until there are no more sub-categories (basically a select your select your select your city, etc.). If you know of a good reference or example off hand, I would appreciate some reference material on how to implement this. I know your time is valuable and I am not asking you to solve all of my problems or write my code for me, I would just like to educate myself so that I can solve my own problems. Thanks --Matt Behrensmr 14:10, 13 January 2008 (NZDT)

I suggest that this kind of data entry problem is easier solved by a specific extension that reads the category information and genates javascript to create the dynamic lists. You may be able to figure out a way to use SimpleForms to do this but you're going to have to get into the javascript side of things. It sounds like a common kind of form - check the other wikimedia projects to see if they are aleady using something similar. In particular Wikiversity has a lot of form templates. They seem to use forms a lot more than Wikipedia.--Rob 22:21, 13 January 2008 (NZDT)