SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Wizard silver trophy Jeremy W.'s Avatar
    Join Date
    Jun 2001
    Location
    Toronto, Canada
    Posts
    9,121
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Dynamically selecting form element?

    How would I do this:

    Code:
    function doUpdate(eva,text)
    {
    	document.form.eva.value=text;
    }
    ...? Eva being a parameter I want to pass into the function to select the form element to have "text" inserted into it?

    J
    SVP Marketing, SoCast SRM
    Personal blog: Strategerize
    Twitter: @jeremywright

  2. #2
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is eva a reference to the element?
    Code:
    function doUpdate(eva,txt)
    {
    	eva.value=txt;
    }
    Or a string holding the name/id of the element?
    Code:
    function doUpdate(eva,txt)
    {
    	document.formName.elements[eva].value = txt;
    }
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev





Bookmarks

Posting Permissions

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