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. Advertising

  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. Advertising

  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. Advertising

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. Viktor

    How to load HTML file into Textarea as Plain Text?

    Viktor, Oct 2, 2003, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    390
    Viktor
    Oct 2, 2003
  2. Augustus
    Replies:
    1
    Views:
    384
    Ken Schaefer
    Sep 10, 2003
  3. Shaiboy_UK
    Replies:
    11
    Views:
    269
    Shaiboy_UK
    Dec 22, 2004
  4. Textarea Inside of a textarea

    , Feb 4, 2006, in forum: ASP General
    Replies:
    6
    Views:
    354
    Anthony Jones
    Feb 5, 2006
  5. Replies:
    1
    Views:
    344
    Bart Van der Donck
    Jul 4, 2007
Loading...

Share This Page