I wanted to teach myself AJAX this weekend so I sat down with Stuart
Landgridge's book and I started to play around. I came up with a little
page that you can add text and images to. You can see it here:
http://www.publicdomainsoftware.org/ajaxExperiment.htm
Click in any box to get the controls with which you can play around.
This function below, askForInput, was working the way I wanted, till I
tried to give it two parameters, one of which was meant to be example
text that would auto-fill the TEXTAREA and give it an intitial value.
While things still work find in IE, now this works incorrectly in
FireFox. In FireFox, whatever value is set initially in this function
becomes the only function that can later be retrieved. Obviously, that
is not what I want. If the software asks people to write in some text,
it should be what they write, and not the initial value, that is then
captured and used. What syntax do I have to use to set the initial
value to FireFox will still see the value that the user types in,
rather than the initial value set here?
function askForInput(int roText, exampleText) {
var divRef = getRefToInputDi v();
var communicationBo xRef =
document.getEle mentById("commu nicationBox");
communicationBo xRef.style.disp lay = "block";
communicationBo xRef.appendChil d(divRef);
divRef.style.di splay = "block";
var area = document.getEle mentsByTagName( 'TEXTAREA')[0];
area.value = exampleText;
var divRef = document.getEle mentById("input Box");
if (divRef.innerHT ML == "" || divRef.innerHTM L == undefined) {
divRef.innerHTM L = exampleText;
}
var divRef = document.getEle mentById("input Div");
var firstChildNode = divRef.firstChi ld;
if (divRef.childNo des.length > 4) {
divRef.removeCh ild(firstChildN ode);
firstChildNode = divRef.firstChi ld;
}
var newTextNode = document.create TextNode(introT ext);
var newLiterature = document.create Element("p");
newLiterature.a ppendChild(newT extNode);
var firstChildNode = divRef.firstChi ld;
divRef.insertBe fore(newLiterat ure, firstChildNode) ;
}
function getInput() {
var divRef = document.getEle mentById("input Box");
var inputText = divRef.innerHTM L;
divRef.innerHTM L = "";
if (inputText == "" || inputText == undefined) {
var area = document.getEle mentsByTagName( 'TEXTAREA')[0];
inputText = area.value;
area.value = "";
}
inputResults = inputText;
var communicationBo xRef =
document.getEle mentById("commu nicationBox");
var lastChildInComm unicationBox = communicationBo xRef.lastChild;
communicationBo xRef.removeChil d(lastChildInCo mmunicationBox) ;
communicationBo xRef.style.disp lay = "none";
if (nextActionToTa keAfterInput == "setTextAction" )
setTextAction() ;
if (nextActionToTa keAfterInput == "setImageAction ")
setImageAction( );
if (nextActionToTa keAfterInput == "setHtmlAction" )
setHtmlAction() ;
if (nextActionToTa keAfterInput == "setBackgroundC olorAction")
setBackgroundCo lorAction();
if (nextActionToTa keAfterInput == "setColorAction ")
setColorAction( );
}