Topic: Best practices for check if element id exist

Hi everybody,

for a dinamic form i use the clear function if a user change the select value but i have problem if the id do not yet exist.

$objResponse->clear("bet_opt", "innerHTML");

On IRC Channel a user said to me to use the script function like that:

$objResponse->script("var d = document.getElementById('bet_opt'); if (d) { d.innerHTML = ''; }");

It runs but i don't like use the script function....
Do you think it's the best practice and the unique way for check if element id exist ?

Thank's

Re: Best practices for check if element id exist

Keep an eye on your program logic.
An object wich isn´t set, can`t be cleared^^

Your welcome to post your code here, i am sure we find a solution

love

sin

Re: Best practices for check if element id exist

Nice topics you are sharing with us. Thanks for this..

Re: Best practices for check if element id exist

I was wondering why you don't like using the script function.

I have used it quite a lot and it seems to add an element of flexability.

An alternative would be to write a js function in the page and use the response cal function.

Ed

If you ever stop learning you may as well dig a hole, crawl in and pull the top over yourself.