#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Location
    CT
    Posts
    16
    Rep Power
    0

    is it possible to change values in an option list?


    I'm trying to make a "mock chatroom" for a project I am doing, and I am trying to edit the buddy list. When the user enters the room, it asks them for a name. I want the name they enter to go into the buddy list, but I'm not sure what the code is, if possible. to change the values in the option list. Here is what I have so far.


    <html>
    <head>
    <title>Untitled Document</title>
    </head>

    <body>
    <script type="text/javascript">
    var userName = prompt("Please enter a username.", "Enter name here.");
    </script>

    <form name="chatRoom" action="#">
    <textarea name="txtChatWindow" cols="90" rows="15"></textarea>
    <select name="buddyList" size="15">
    <option value="buddy1">buddy1</option>
    <option value="buddy2">buddy2</option>
    <option value="buddy3">buddy3</option>
    </select>
    <br />
    <input name="txtEnter" type="text" size="90" />
    <input type="button" onclick="sendText()" value="Send" />
    </form>

    </body>
    </html>
  2. #2
  3. mod_dev_shed
    Devshed Supreme Being (6500+ posts)

    Join Date
    Sep 2002
    Location
    Atlanta, GA
    Posts
    14,817
    Rep Power
    1099
    So when I enter my name and click "Chat", or whatever, you want to add the username I choose to the list of people. JavaScript is client side, so only I'll see my name added. Did you realize this? and is that what you want?
    # Jeremy

    Explain your problem instead of asking how to do what you decided was the solution.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Location
    CT
    Posts
    16
    Rep Power
    0
    It's for a school project. We have to make a web site for a band, and on the website I'm making a fake chat room. I only need to have one user in the room, so I would want buddy1's value to equal whatever username the user puts in. Then I'll put fake names for buddy2 and buddy3. Then when the user types text and hits send the value of the text box will be added to the value of the textarea. The area where I'm having trouble is changing the value of the list box to what the user enters in the prompt.

    In short, yes I want the name that is entered to appear on the list.
  6. #4
  7. Senior Member
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Aug 2003
    Location
    Toronto
    Posts
    1,614
    Rep Power
    13
    selectname.options[selectname.options.length] = new Option(displayname, value)
    webM

    for $i(0..20){for($j=0;$j<=$i;$j+=2){print pack(qq{H2},
    substr(qq{5f5745424d415354415f},$j,2));}print qq{\n};};

IMN logo majestic logo threadwatch logo seochat tools logo