PDA

View Full Version : new to java help pls how to insert text at cursor


parot
06-03-2009, 08:54 AM
Hi folks

Sorry if this sounds "simple" but I am very new to java - give php and I love it, any how I have this function

function ChangeText()
{
if (document.getElementById)
{ // DOM3 = IE5, NS6
document.getElementById('hideShow').style.visibility = 'hidden';
}
else
{
if (document.layers)
{ // Netscape 4
document.hideShow.visibility = 'hidden';
}
else
{ // IE 4
document.all.hideShow.style.visibility = 'hidden';
}
}

var x = document.editform.textarea1.value;
var newHTML = document.editform.idtest.value;
var curtextval = document.getElementById(newHTML);
curtextval.innerHTML = x;

}


What should happen (and does in principle) is the user can edit the text in a new text area. The textarea has a series of buttons to insert BBcode. problem is that when I test it the BBCode buttons ONLY insert at the end of the text (the text is bought through via a php query from a MySql db).

I have tried adding a += i.e.

var x = document.editform.textarea1.value+=;

but that just stops the function from working.

Any ideas?

Thanks in advance