Form action

Results 1 to 2 of 2

Thread: Form action

  1. #1
    Join Date
    Dec 1969

    Default Form action

    I am trying to change the form action according to a variable passed into a form, the following code won&#039;t work - it takes the value of form_action2 for both cases: <BR><BR> function change_action()<BR> {<BR> var form_action1 = "insert_faults.asp";<BR> var form_action2 = "fault_update_form.asp";<BR> <BR> if (document.faults.form_status.value == "add")<BR> {<BR> document.faults.action = form1<BR> }<BR> if (document.faults.form_status.value = "update")<BR> {<BR> document.faults.action = form2<BR> } <BR> }<BR><BR>form_status is a hidden value in the form and the function is called when the page is loaded. Does anyone has any idea of how to fix this

  2. #2
    Join Date
    Dec 1969

    Default That's because

    On your second IF statement, you have:<BR>if (document.faults.form_status.value = "update") <BR>--------------------------------------^<BR><BR>See that? One equal sign, which SETS document.faults.form_status.value equal to "update", instead of comparing. Change it to "==" and you should be good to go.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts