FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

previsualize form problem

 


alalex
i have a form, and i want to make it possible to previsualize it.
so i created a div with id previsualize. and a button in the form calls the function previsualize. here is the function:
Code:
function previsualize()
{
   var title = document.modificar.titulo.value;
   var content = document.modificar.contenido.value;
   var author = document.modificar.autor.value;
   var preview = title + "\n" + content + "\n" + "By: " + author;
   document.previsualize.innerText = (preview);
}

it says that the problem is this: The object doesnt accept that property or method. But it refers to a line that doesnt exist!
shamil
Change
Code:
document.previsualize.innerText = (preview);
to
Code:
document.getElementById('previsualize').innerText = (preview);
Hope it will work.
Kaneda
innerText is only supported in IE. Mostly you can use innerHTML instead.

And yes, as shamil says, avoid using document.[element_id] - use document.getElementById(element_id) instead.
alalex
ok thanks!! im still learning javascript!
alalex
ok i decided to change from a div to a textfield, i thought it would be easier... but it still doesnt work! Sad here is the code:
Code:

function previsualize(){
   var titulo = document.modificar.titulo.value;
   var contenido = document.modificar.contenido.value;
   var autor = document.modificar.autor.value;
   var preview = titulo + "\n" + contenido + "\n" + "Aviso por:  " + autor;
   var field = document.prev_form.prev.value;
   field = preview;
}

There are bits in spanish, but they are not importnant for the code..
it says that var field = document.prev_form.prev.value;
is not an accesible object...
Reply to topic    Frihost Forum Index -> Scripting -> Html, CSS and Javascript

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.