How do I clear an iframe form in a chat application?
This chatroom is a online help chat, and each person that logs in gets their own room. The admin sees a list and can enter any open chat (up to 4 chats simultaneously). For the chat window, I have a main page that has two iframes, the display and the form. The form enters data into two related tables (chatLogs) & (chatRooms). There is minimal CF code on the form page, because it has goes to the display page to process the form data. The display has a JS script refreshing it every 5 seconds. The problem is that every time I send a message, it shows what I just typed in the textarea AFTER I submit the form. So I have to manually delete the text every time I want to type in another message.
The functionality that I want is that it either clears after I run the insert statement, or clears on load. Any process that provides the same result is fine.
Though research, I found that the <body onload="document.forms.reset()"> function does not work. The only thing that I have found that did anything is <form name="form1" onsubmit="document.forms[i].reset();">. Unfortunately, it clears the form before running the insert statement. Also, if I reload the whole page (by re-entering the URL) it clears properly. Niether of these work:
window.location = "shoutform.cfm?" + frm.chatID.name + "=" + frm.chatID.value + frm.text.name + "=" + frm.text.value;
parent.location = "inc_shoutbox.cfm?" + frm.chatID.name + "=" + frm.chatID.value;
There is far more current functionality than I have explained. If you wish to see a sample of code or have a detailed explanation of the process, just let me know. It completely works, I just have this one tiny bug.
This project has been my first exposure to JS as a intermediate CF programmer. I have been trying to build it mostly with CF, but I still need JS functionality that CF is incapable of delivering.