Forum Moderators: open

Message Too Old, No Replies

Dynamically changing the action value in a form

Need top open different pages depending on selection made within a form

         

delvsie

9:16 pm on May 21, 2003 (gmt 0)

10+ Year Member



Hi folks,

I have a slight problem that I hope someone can help me with. I need to be able to open different pages from a form depending on the selection that is made fom one specific select field.

i.e. I'm trying to change the value of the action attribute of the form.

I don't seem to be able to get anything to work.

Can anyone help me.

Cheers Delvsie

jatar_k

9:27 pm on May 21, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



if (document.formname.select1[document.formname.select1.selectedIndex].value == 'whatever') {
document.formname.action = 'page1.php';
} else {
document.formname.action = 'page2.php';
}
document.formname.submit();

I think that's right

HocusPocus

12:54 am on May 22, 2003 (gmt 0)

10+ Year Member



Just to safe you 5 mins-
I would have thought the first line should be

if (document.formname.select1.options.[document.formname.select1.selectedIndex].value == 'whatever')

jatar_k

1:11 am on May 22, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



sorry, thanks HocusPocus

delvsie

9:08 am on May 22, 2003 (gmt 0)

10+ Year Member



Just a quick note to say thanks to you both for your help.

It was just what the doctor ordered!

Brilliant.

Cheers