Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2004
    Location
    Digital Texas
    Posts
    55

    Javascript Problem

    Is it possible for me to have text on a website update dynamically as a user inputs info into a <input> box?

    ex. <input>::user inputs "howdy" into textbox

    ::On website::
    - Your Input: howdy

    I dont want them to have to refresh the page, I want the text to reflect whatever theyre typing into the input box, as theyre typing it.

    ex. Your input: would show "h" then "ho" then "how" then "howd" then "howdy", respectivly as they typed the word "howdy" into the input box.

    Again, is this possible?

  2. #2
    Join Date
    Mar 2004
    Location
    USA
    Posts
    4,342
    Sure...

    You will make a <span id=name"></span>

    Onblur(i think) for the text add "update_span();"

    and update_span takes:

    document.span.innertext=document.textboxname.value

    something like that would do..

    Dont know how you got to douple post thou (empty one)

    Peace,
    Testing 1.. Testing 1..2.. Testing 1..2..3...

  3. #3
    Join Date
    Jul 2002
    Location
    The Big Easy -New Orleans
    Posts
    341
    Are you asking to change the page THAT user is seeing, or pages that OTHER users are seeing as they type?

    The first wouldn't be hard at all...

    The second, I've seen a similar thing done with Cache' Server Pages, where as the user was typing a javascript function was talking back to the server. It was pretty cool actually. As they typed the last name, it talked back to the webserver without refreshing the page and filled in the text for them. So if they typed "J" they got James, but when they hit "o" for "Jo" it changed it to "Jones"... You could probably do that with other setups as well. But I've actually seen it done with Cache from Intersystems.

  4. #4
    Join Date
    Jun 2004
    Location
    Digital Texas
    Posts
    55
    Itll be for the page that user is seeing. Its for reflecting some url values. Not a chat program.

    Ex, a preset is http://www.mysite.com/
    and as users input values into the input box, itll display
    http://www.mysite.com/whatevertheuse...heirinputingit

    Aziz: Thanks, Ill try that.

    And labgeek: as far as the users "communicating" with the server, thatd be easy, just use a mysql database, preload it with all ur users, then query them and store to an array. as the users updates their input field, reflect it from the array. Dunno how to do it in javascript, but Id do something along those lines in php

    If anyone has any more advice or better examples on how to get it working, please do tell

  5. #5
    Join Date
    Mar 2004
    Location
    USA
    Posts
    4,342
    Originally posted by Nyture
    Itll be for the page that user is seeing. Its for reflecting some url values. Not a chat program.

    Ex, a preset is http://www.mysite.com/
    and as users input values into the input box, itll display
    http://www.mysite.com/whatevertheuse...heirinputingit

    Then what I said will not work, I thought you wanted to just change what the user sees..

    What you want can also be done easily(something like Google Suggests). You just have to decide which approach to take.

    As far as my knowledge I would say I have to use Javascript (load all the variables into javascript lets say from MYSQL and then just do matching)..

    If you learn Ajax, it would be just perfect

    Peace,
    Testing 1.. Testing 1..2.. Testing 1..2..3...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •