text file data into textarea

Discussion in 'Javascript' started by Junoon, Apr 1, 2006.

  1. Junoon

    Junoon Guest

    hi all,

    I am trying to get the values of the item selected in a select list box
    into a textarea, but the code is not working....Where am i going
    wrong????

    whenever i click on any item in the list, the corresponding value for
    it will get displayed in the text area.....

    Also, is there a way to get data from a text file into the textarea,
    when i select an item in the list.

    *****************************************
    <html>
    <head>
    <script language="javascript">
    function getit(){
    var data='...\n';
    if(data.value){
    data=document.form1.sel1.options[document.form1.sel1.SelectedIndex].value+"....\n";

    document.form1.tex1.value=data;
    }
    }

    </script>
    </head>

    <body>
    <form name="form1" onsubmit="getit(); return false">
    <table>
    <tr><td>Issue: </td>
    <td><select name="sel1" size= "3">
    <option value="pc problem">error 0680
    <option value="modem problem">error 0633
    <option value="network problem">error 0721
    </select>
    </td>
    <td>Resolution: </td>
    <td><textarea name="tex1" rows=7 cols=30 wrap=virtual></textarea>
    </td>
    </tr>

    <TR>
    <TD COLSPAN=2 ALIGN=center>
    <INPUT TYPE=submit VALUE="Submit form"><BR>
    <INPUT TYPE=reset>
    </TD>
    </TR>
    </table>
    </form>
    </body>
    </html>

    Rgds,
     
    Junoon, Apr 1, 2006
    #1
    1. Advertisements

  2. Junoon

    Guest

    Junoon wrote:
    > hi all,
    >
    > I am trying to get the values of the item selected in a select list box
    > into a textarea, but the code is not working....Where am i going
    > wrong????
    >
    > whenever i click on any item in the list, the corresponding value for
    > it will get displayed in the text area.....


    This sounds like it is already working. I assume that this is what you
    want.

    > <form name="form1" onsubmit="getit(); return false">
    > <table>
    > <tr><td>Issue: </td>
    > <td><select name="sel1" size= "3">


    I think you want something like this

    <form name="form1">
    <table>
    <tr><td>Issue: </td>
    <td><select name="sel1" size= "3" onchange="getit();">
     
    , Apr 1, 2006
    #2
    1. Advertisements

  3. Junoon

    Junoon Guest

    Hi Peter,

    tried the below code as you suggested. It does not give me an error but
    it does not work also.

    I was previously trying to use the This.form keyword in the getit()
    function.....

    like this.....
    -------------------
    function getit(frm){ ...................

    and in the onChange event....
    ------------------------------------------
    <td><select name="sel1" size= "3" onchange="getit(this.from);">

    and change the statements in the function to ......
    --------------------------------------------------------------------
    data=document.frm.sel1.options[document.frm.sel1.SelectedIndex].value+"....\n";
    }
    document.frm.tex1.value=data;
    }
    ==========================
    This code does not give an error, but it does not work also, only
    getting .....in the textarea......
    ==========================
    <html>
    <head>
    <script language="javascript">
    function getit(){
    var data='...\n';
    if(data.value){
    data=document.form1.sel1.options[document.form1.sel1.SelectedIndex].value+"....\n";
    }
    document.form1.tex1.value=data;
    }

    </script>
    </head>

    <body>
    <form name="form1">
    <table>
    <tr><td>Issue: </td>
    <td><select name="sel1" size= "3" onchange="getit();">
    <option value="pc problem">error 0680
    <option value="modem problem">error 0633
    <option value="network problem">error 0721
    </select>
    </td>
    <td>Resolution: </td>
    <td><textarea name="tex1" rows=7 cols=30 wrap=virtual></textarea>
    </td>
    </tr>

    <TR>
    <TD COLSPAN=2 ALIGN=center>
    <INPUT TYPE=submit VALUE="Submit form"><BR>
    <INPUT TYPE=reset>
    </TD>
    </TR>
    </table>
    </form>
    </body>
    </html>
     
    Junoon, Apr 2, 2006
    #3
  4. Junoon

    Junoon Guest

    Just to let you know, was previously getting a message....

    "document.frm.tex1.value is Null or not an Object"
     
    Junoon, Apr 2, 2006
    #4
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. bienwell
    Replies:
    2
    Views:
    4,441
    bienwell
    Jun 17, 2006
  2. Viktor

    How to load HTML file into Textarea as Plain Text?

    Viktor, Oct 2, 2003, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    495
    Viktor
    Oct 2, 2003
  3. Rick Csucsai

    how to insert text into middle of textarea

    Rick Csucsai, Jun 21, 2005, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    353
    Harolds
    Jun 24, 2005
  4. Shaiboy_UK
    Replies:
    11
    Views:
    420
    Shaiboy_UK
    Dec 22, 2004
  5. Replies:
    5
    Views:
    481
  6. lawrence
    Replies:
    3
    Views:
    164
    kaeli
    Jun 3, 2004
  7. Paul Gorodyansky
    Replies:
    7
    Views:
    804
    Martin Honnen
    Feb 6, 2005
  8. cyprian
    Replies:
    0
    Views:
    171
    cyprian
    Jul 18, 2007
Loading...