Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jul 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    making a dynamic textarea name

    Hi, sorry i'm a major newbie at javascript. Anyway, my question:

    I have a form called frmProfile, a textarea called article and a button with an onclick event set to addtext(this.form)

    I have this function:

    Code:
    addtext(form){
    }
    With this piece of javascript in it:

    Code:
    var Article = form.article.value;
    to get what is in the text area into a variable

    The problem is this, i want to use this code for multiple forms on different pages, however all my text areas have different names. Now i was wondering is there anyway to add a variable to the js code so that it's easy to change all the times i refer to form.article.value?

    I tried using var textareaName = "article"; and then i could change it on each of my pages and change the js code to something like:

    Code:
    var Article = form.textareaName.value;
    But you can't do that, well it doesn't work, guessing it's because the code does not realize it's suppose to be a variable and thinks that's the name of the textarea. Is there a sort of operator that tells it that it's a variable and not the name.

    Thanks

    sorry about the title wasn't sure of how to describe my problem

  • #2
    Senior Coder
    Join Date
    Apr 2005
    Posts
    1,051
    Thanks
    0
    Thanked 0 Times in 0 Posts
    use the DOM

    document.forms[FormIndex].inputName;

    or you could enumerate all forms and parse through them that way.
    public string ConjunctionJunction(string words, string phrases, string clauses)
    {
    return (String)(words + phrases + clauses);
    }
    <--- Was I Helpfull? Let me know ---<

  • #3
    New Coder
    Join Date
    Jul 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Sorry don't understand

    What do i put for inputName? I can put the name of the textarea but that's what i have already. I have forms on different pages with textareas with different names and one lot of code which refers to document.forms[FormIndex].inputName; alot but i'll need to change the input name on each page a load of times if i left it like it

    Cheers
    Last edited by vinnieza; 07-03-2006 at 06:03 PM.


  •  

    Posting Permissions

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