Jump to content
MakeWebGames

Updating an area with new text inputed by user?


Recommended Posts

Posted

I want to create an ajax mud and I was wondering how to update an area of text with new text that is retreived from the mySQL database from the command giving by the user?

Posted

Re: Updating an area with new text inputed by user?

element.innerHTML is a very common method.

The innerHTML property sets the contents of the element and causes the browser to render any html that's included.

Posted

Re: Updating an area with new text inputed by user?

Copied and pasted with permission to preserve the continuity of the thread.

[20:58] <floydian> what's confusing ya about what I said in the forum?

[20:58] <Sim> I dunno. what I do with innerHtml?

[20:59] <floydian> first, you need to "get" the element you're putting the response into

[20:59] <floydian> have you done that?

[20:59] <Sim> hmm No. I don't know where to even begin with ajax. I downloaded an ajax chat example to try to learn from but it doesn't use mySQL. it uses a txt file.

[21:00] <floydian> (and to make the thread make sense, I'll post what's said here so it closes up that thread nicely)

[21:00] <Sim> Sounds good to me.

[21:00] <floydian> it sounds like you need to study some ajax examples then

[21:01] <floydian> there's lots of them out there

[21:01] <Sim> http://ce.pastebin.com/m26c7883c

[21:02] <Sim> I can figure out how to write to mySQL file without refreshing page.

[21:02] <Sim> just not read from and update from mySQL

[21:03] <Sim> Is it as simple as echoing? ;]

[21:03] <floydian> #

[21:03] <floydian> function ajax_read(url) {

[21:03] <floydian> when you do that function call

[21:03] <floydian> the URL you put in there

[21:03] <floydian> will be executed as a normal page would

[21:03] <floydian> and yes, anything you echo from that file that is executed

[21:04] <floydian> would be placed into the web page

[21:04] <floydian> by

[21:04] <floydian> document.getElementById("chatwindow").innerHTML = xmlhttp.responseText;

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...