|-----Original Message----- |From: "Matt Palermo" <[EMAIL PROTECTED]> |Sent: Thursday, July 24, 2003 3:35 PM | |> I am trying to create a submit button out of a hyperlink using the |> following |> code: |> |> (this is in a file called index.html) |> <A DEFANGED_href="javascript:go_where_my_variable_says('this.php');">this |> page</a> |> |> <DEFANGED_SCRIPT LANGUAGE="JavaScript"> |> <!-- |> function go_where_my_variable_says(where) |> { |> document.forms[0].action = where; |> document.forms[0].submit(); |> } |> //--> |> </DEFANGED_SCRIPT> |> This works fine as an html document, however, when I try to echo the |> same code out in a PHP page, it gives me javascript errors. I am using |> the following to echo it out in PHP: |> |> echo " |> <A href=\"javascript:go_where_my_variable_says('this.php');\">this |> page</a> |> |> |> <DEFANGED_SCRIPT LANGUAGE=\"JavaScript\"> |> <!-- |> function go_where_my_variable_says(where) |> { |> document.forms[0].action = where; |> document.forms[0].submit(); |> } |> //--> |> </DEFANGED_SCRIPT> |> "; |> |> This displays the link fine for the submit hyperlink, but it gives the | |> javascript error: |> |> Error: Object doesn't support this property or method. |> Code: 0 |> Like I said before, this code works perfectly fine if I have it an html |> document. |> |> Anyone got any ideas? |> |> Thanks, |> Matt | |From: Jim Lucas [mailto:[EMAIL PROTECTED] |Sent: Thursday, July 24, 2003 6:40 PM |To: Matt Palermo |Subject: Re: [PHP] Link acting as a submit button | |Your javascript is wrong. | |change this | document.forms[0].action = where; |to this | document.forms[0].action.value = where; | |Jim Lucas | |----- Original Message ----- On Jul 24, 2003, "Matt Palermo" claimed that:
|Fixing the javascript that you specified still gave me the same |errors... Got any more suggestions? | |Thanks for your help, | |Matt When you converted it to PHP did you include the <form> tags? I received a similar error until I added the <form> tags. Other than that, try adding a name value to the form and change 'document.forms[0].action = where;' to 'document.form_name.action = where;' Except for the fact that I don't have this.php, it appeared to work for me after the addition of the form tags as posted. Jeff -- Registered Linux user #304026. "lynx -source http://jharris.rallycentral.us/jharris.asc | gpg --import" Key fingerprint = 52FC 20BD 025A 8C13 5FC6 68C6 9CF9 46C2 B089 0FED Responses to this message should conform to RFC 1855. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php