Click to See Complete Forum and Search --> : changing a meta tag based on a textbox value


myztacia
07-05-2005, 12:09 PM
I'm creating a php/mysql chatroom and would like to add some javascript to enhance it. The goal: to not use frames...it would be a piece of cake if I used frames [I've created several chats before]. The chat is set to automatically refresh every 15 seconds. When a user is typing in the textarea and the chat refreshes, it erases what they've typed already. What I want to do is to put whatever is typed (using onChange) on the URL part of the meta tag...so that when it refreshes, php may grab the value of the URL and put it into the textbox again [on the refreshed page], then set focus to that box [on the end].

I REALLY am clueless when it comes to javascript, so I have virtually nothing to begin with.

form:

<form name='chatform' method='post' action='http://kittentracks.com/chat.php'>
Message: <input type='text' name='message' size=40 maxlength=255 onChange='urlChange(chatform.message.value);'> &nbsp; &nbsp; &nbsp;
<input type='submit' name='post_msg' value='Submit'>
</form>


javascript: - I have no idea what to do for here x.x

<script>
function urlChange(message)
{
var message = message;
}
</script>


meta tag: - replace $message with whatever the javascript returns

<meta http-equiv='refresh' content='2;url=http://kittentracks.com/chat.php?message=$message'>


I'm sorry you'll basically be coding this for me if you choose to help me...I honestly have no idea where to go with it x.x

Kravvitz
07-05-2005, 10:31 PM
onchange is only triggered when the element loses focus and the value of the element has changed.

You should use onkeypress, onkeydown, or onkeyup.

myztacia
07-05-2005, 10:32 PM
Alright...I think I knew that, lol.

How would I get it to post the appropriate value at the end of the URL for the refresh tag?

Kravvitz
07-06-2005, 12:03 AM
Are you using HTML or XHTML?

I'm asking because HTML doesn't allow the id attribute on <meta> elements, while XHTML does.

BigMoosie
07-06-2005, 12:07 AM
I would suggest not refreshing the page but using javaScript to request the data and dynamically modify the page.

Kravvitz
07-06-2005, 02:09 PM
BigMoosie has a good point, this would be an excellent project to gain experience with XMLhttpRequest, which many refer to as AJAX. (http://www.google.com/search?q=XMLHttpRequest+OR+AJAX+%7Etutorial)

Another way would be to simply use one of the location object's methods or properties to reload the page instead of using the meta-refresh tag.