• Resolved Cityproject

    (@nikpar)


    Hello,
    At the form i am making i need to target the input elements specifically. I was wandering, is it possible to use the field ID (that goes as ID at the parent div) in the name attribute of the included form element (input, select or w/e)? I need to use it in combination with another autofill plugin that targets the form elements directly with use of name tag or class or id. ID can’t be dublicate so i thought to put it as name of these elements.

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author EDGARROJAS

    (@edgarrojas)

    Hello!

    The id field is added at the container of the whole field (which generally has a label and a input field). If you want to get the value of an input you could use a javascript like this (assuming you are using a text input with id ‘rnfield1):

    document.querySelector(‘#rnField1 input’).value

    Regards!

    Thread Starter Cityproject

    (@nikpar)

    Thanks for your answer. I dont want to get the value of the input, i need to set the name attribute of the input to the same as the ID set to the field.

    eg. based on you example, i need the input to become <input … name=’rnField1′ …>

    Plugin Author EDGARROJAS

    (@edgarrojas)

    oh got it, then try something like this:

    document.querySelector(‘#rnField1 input’).setAttribute(‘name’,’rnField1′);

    Regards!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘how to use field id as name of input?’ is closed to new replies.