Skip navigation.

Harold's Home

XML version of this site

PHP Scripts

CLI fun
Mail on 404
HB-NS (NewsScript)


APOD to Desktop
Dreamweaver Extensions


Other stuff
Central Grinder

OOOk Default:

VJ stuff
VJ Tools
Sample Movies


Adding forms in MCMS

I'm working in MCMS and trying to add a form to pages I create. Unfortunately I cannot add a real form as the entire page already is one and nested forms are not allowed in HTML. Normally when things are not allowed you can sneak around and do them anyway with a reasonable expectation of getting them to work as browsers are very tolerant of errors and whatnot.
Not so in this case!

I did manage to find a way to work around it though by just inserting the needed form elements without <form> tags and then using a very small bit of custom javascript. This custom script will rewrite the normal action url of the resident form and overwrite a few of the default values with nothing. This could probably be handled a bit better but I'm unsure of whether javascript supports a function like PHP's unset().
function doForm()
//strip surplus unwanted values that reside by default in MCMS pages
theform.unwanted.value = "";
theform.unwanted2.value = "";

And then the search button can have an onClick event as follows:
<input onClick="javascript:doForm();" type="submit" value="Search" name="cmdSearchSubmit" />

Unfortunately I cannot add javascript to my pages as they're deleted right away, so I'm stuck in limbo with nothing to show for my efforts accept an angry post.

Update: good friend Jurjan (of Virtual Pet Rock fame) emailed me to suggest that if Microsoft's crappy management system deletes script tags I might be able to put the javascript into the onclick handler of the submit button. This works like a charm! So instead of calling a function I just put the entire javascript there like so:
<input onclick="javascript:theform=document.Form1; theform.method='get'; theform.action='' +theform.linktype.value+ '&SF='+theform.SF.value+ '&ST=' +theform.ST.value+'&WW=' +theform.WW.value; theform.__EVENTARGUMENT.value = ''; theform.__VIEWSTATE.value = ''; theform.__EVENTTARGET.value = '';theform.submit();" type="submit" value="Zoek" name="cmdSearchSubmit" />

It's may be a bit clunky but it works.

Show all items | Read all items

About, copyright, privacy and accessibility | Mail