You are not logged in.
Hello,
I'm sorry for my poor english, i'm french. So this is my problem:
I want to modify the color of a Xinha textarea's value with a script directly from a listbox. Here is my code :
// My script
<script language="javascript">
function change_risk(valeur) {
var reg = new RegExp("<font color=(\"|\')#[0-9a-fA-F]{6}(\"|\')>","gi");
document.form.vulnerability_name.value = document.form.vulnerability_name.value.replace(reg,"<font color='" + valeur + "'>");
}
</script>
// My list
<select onChange="change_risk(document.form.risk.options[document.form.risk.selectedIndex].value)" name="risk">
<option value="#ff0000">High</option>
<option value="#00ff00">Medium</option>
<option value="#0000ff">Low</option>
</select>
// My textarea
<textarea id="vulnerability_name" name="vulnerability_name" rows="3" cols="100">
<center><big><font color="#000000"><b>Bla bla bla bla</b></font></big></center>
</textarea>
I found that it works fine if I first convert my Xinha's textarea in HTML (with the HTML button in the Xhina's toolbar) before I make the change in the listbox. If I don't do that, the textarea's value doesn't change... but I want that it works anytime.
What can I do to resolve this ?
Maybe I could modify my javascript to automatically convert the value in HTML, apply the change and convert it in Xhina's format (without clicking on any button of the toolbar), but i don't know how. I need help.
Thank you for any idea
Cedric
Last edited by cedric57 (2007-04-16 11:14:49)
Offline
No idea ?
So I suppose it's not possible...
Thank you
Cedric
Offline
var html = xinha_editors.yourEditor.outwardHtml(xinha_editors.yourEditor.getHTML());
// do something with it
xinha_editors.yourEditor.setHTML(xinha_editors.yourEditor.inwardHtml(html))
Offline
var html = xinha_editors.yourEditor.outwardHtml(xinha_editors.yourEditor.getHTML());
// do something with it
xinha_editors.yourEditor.setHTML(xinha_editors.yourEditor.inwardHtml(html))
Offline
Ok I will look at this
Thanks for your help
Offline
I did :
<script language="javascript">
function change_risk(valeur) {
var reg = new RegExp("<font color=(\"|\')#[0-9a-fA-F]{6}(\"|\')>","gi");
var html = xinha_editors.vulnerability_name.outwardHtml(xinha_editors.vulnerability_name.getHTML());
xinha_editors.vulnerability_name.setHTML(xinha_editors.vulnerability_name.inwardHtml(html));
document.form.vulnerability_name.value = document.form.vulnerability_name.value.replace(reg,"<font color='" + valeur + "'>");
}
</script>
But it doesn't change anything. I don't understand what i have to do with your code... I thought that it permits to convert the value in HTML and then permits to change its color. But I'm not sure how to use it.
Can you give me more details about these properties ?
Cedric
Offline
<script language="javascript">
function change_risk(valeur) {
var reg = new RegExp("<font color=(\"|\')#[0-9a-fA-F]{6}(\"|\')>","gi");
// the below retrieves the Xinha content and stores it in the variable html; now you can do things with it
var html = xinha_editors.vulnerability_name.outwardHtml(xinha_editors.vulnerability_name.getHTML());
// change it
html = html.replace(reg,"<font color='" + valeur + "'>");
// then put it back in the editor
xinha_editors.vulnerability_name.setHTML(xinha_editors.vulnerability_name.inwardHtml(html));
// this does nothing, because the editor area is independent from the textarea
//document.form.vulnerability_name.value = document.form.vulnerability_name.value.replace(reg,"<font color='" + valeur + "'>");
}
</script>
Offline
Great ! It works !!!
Thank you very much and very good job for your HTML editor (probably the best i've found)
See U
Offline