PDA

View Full Version : Changing form action by name


Seven^3
01-09-2003, 03:07 AM
I need to change the action of an automatically generated form if it's current action (calling a particular CGI script) is invalid.
Here's what I'ver got so far:function altAction (){
var whichIs = document.getElementsByName('dropdown').action;
if (whichIs.indexOf('siteadmin') != -1){
document.getElementsByName('dropdown').action = 'http://...';
}
} The only thing I can't figure out is how to call the function so it actually works (putting an onLoad the <body> tag didn't work, btw).

glenngv
01-09-2003, 03:13 AM
so the form name is 'dropdown'?

function altAction (){
var f = document.dropdown;
if (f.action.indexOf('siteadmin') != -1){
f.action = 'http://...';
}
}

...

<body onload="altAction()" ...>

Seven^3
01-09-2003, 10:41 PM
Legend! :D