Page 1 of 1

Why Event handler treated as text?

Posted: Wed Apr 02, 2008 8:08 am
by coolin
Hi I'm trying to tweak a large php application & have tried adding the following line into the main code but it just results in the line printing out onto the screen rather than executing it

Code: Select all

onload=\"submitForm();\"
I'm sure there's an easy answer though I have tried a number of ways, being a bit new 'n'all, any pointers would be much appreciated :banghead:

Re: Why Event handler treated as text?

Posted: Wed Apr 02, 2008 8:17 am
by aceconcepts
The slashes basically apply/allow the quotation marks with <?PHP tags.

Re: Why Event handler treated as text?

Posted: Wed Apr 02, 2008 8:40 am
by EverLearning
Post a little more code :)

Re: Why Event handler treated as text?

Posted: Thu Apr 03, 2008 9:11 am
by coolin
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: Posting Code in the Forums to learn how to do it too.


Thanks, that's right removing the backslashes results in a parse error:Unexpeceted Tstring message, here is some of the surrounding code included

Code: Select all

                       </div>
                    </div>
                    <div class=\"edit_ad_links\">
                    
 
    <div>
                            <a href=\"".$this->db->get_site_setting
 
('classifieds_url')."?a=1&b=edit_image\" class=\"edit_ad_links\">
                                ".urldecode($this->messages
 
[648])."
                            </a>
                        </div>
                    </div>
                    <div class=\"end_sell_process_link\">
                        <div>
                            <a href=\"".trim($this->db-
 
>get_site_setting('classifieds_url'))."?a=98\" class=\"end_sell_process_link\" >
                                ".urldecode($this->messages
 
[188])."
                            </a>
                        </div>
                    </div>
                </div>
            
 
</div>
        </td>
    </tr>
</table>
<br />
    
 
onload=\"submitForm();\"
 
</form>\n";
 
            $this->display_page($db);
    
            $this-
 
>body .="</div>"; //End main Container  
            $this->body .="
                        </td>
                    </tr>
                </table>
                ";
                    
                    
                    
            return true;
        }
        
 
else
        {
            return false;
        }
    }  //end of function 
 
classified_billing_form
 
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
    function 
 
payment_choices_cc_row($payment_types_accepted)
    {
         // This row gets its own 
 
function since it's used in a couple different places
 
        $type='radio';
        $this-
 
>sql_query = "sele
 

~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: Posting Code in the Forums to learn how to do it too.

Re: Why Event handler treated as text?

Posted: Thu Apr 03, 2008 9:49 am
by pickle
I'd recommend doing all your function calls before you output & store that in a string. Then, put your output in heredocs so you don't need to put all those escapes in.

Re: Why Event handler treated as text?

Posted: Thu Apr 03, 2008 10:33 am
by EverLearning
onload is an event. As such it has to be attached to some element
Supported by the following HTML tags:
<body>, <frame>, <frameset>, <iframe>, <img>, <link>, <script>
and not by itself in the middle of the HTML, like in your code.

Take a look at W3Schools Onload event

Re: Why Event handler treated as text?

Posted: Wed Apr 09, 2008 8:59 pm
by coolin
Thanks Forum Commoner, that's quite right :mrgreen: