* Thus wrote Matt Palermo ([EMAIL PROTECTED]):
> 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 href="javascript:go_where_my_variable_says('this.php');">this
> page</a>
>  
>  
> <SCRIPT LANGUAGE="JavaScript"> 
> <!-- 
> function go_where_my_variable_says(where) 
> {
>     document.forms[0].action = where;
>     document.forms[0].submit(); 
> } 
> //--> 
> </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>
>  
>  
> <SCRIPT LANGUAGE=\"JavaScript\"> 
> <!-- 
> function go_where_my_variable_says(where) 
> {
>     document.forms[0].action = where;
>     document.forms[0].submit(); 
> } 
> //--> 
> </SCRIPT>
> ";

No need to echo out the statement, better to use this method so you
dont have to escape each and every " existing:

// leave php to output html ?>
<A href="javascript:go_where_my_variable_says('this.php');">this
page</a>


<SCRIPT LANGUAGE="JavaScript"> 
<!-- 
function go_where_my_variable_says(where) 
{
    document.forms[0].action = where;
    document.forms[0].submit(); 
} 
//--> 
</SCRIPT>
<?php // now back in php mode

>  
> 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?

With  that being said I dont see a php problem here.


Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to