Why Event handler treated as text?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
coolin
Forum Newbie
Posts: 21
Joined: Sun Mar 16, 2008 1:44 pm

Why Event handler treated as text?

Post 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:
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Re: Why Event handler treated as text?

Post by aceconcepts »

The slashes basically apply/allow the quotation marks with <?PHP tags.
User avatar
EverLearning
Forum Contributor
Posts: 282
Joined: Sat Feb 23, 2008 3:49 am
Location: Niš, Serbia

Re: Why Event handler treated as text?

Post by EverLearning »

Post a little more code :)
coolin
Forum Newbie
Posts: 21
Joined: Sun Mar 16, 2008 1:44 pm

Re: Why Event handler treated as text?

Post 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.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: Why Event handler treated as text?

Post 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.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
EverLearning
Forum Contributor
Posts: 282
Joined: Sat Feb 23, 2008 3:49 am
Location: Niš, Serbia

Re: Why Event handler treated as text?

Post 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
coolin
Forum Newbie
Posts: 21
Joined: Sun Mar 16, 2008 1:44 pm

Re: Why Event handler treated as text?

Post by coolin »

Thanks Forum Commoner, that's quite right :mrgreen:
Post Reply