1

How can I replace all input titles value in a form with input or textarea values using Jquery and 'each' ?

<form id="id001" action="" method="post">
    <fieldset id="F001">
    <legend>F001 : Consulter mes informations professionnelles</legend>
    <div id="msg"></div>
    <label for="EMPLOYEE_NUMBER">
        Matricule de l'agent:
    </label>
    <input name="EMPLOYEE_NUMBER" type="text" id="EMPLOYEE_NUMBER" value="ID999" readonly="readonly" />
    <br /> 
    <label for="LAST_NAME">
        Nom:
    </label>
    <input type="text" name="LAST_NAME" id="LAST_NAME" value="Test" title="" />
    <br /> 
    <label for="FIRST_NAME">
        Prénom:
    </label>
    <input type="text" name="FIRST_NAME" id="FIRST_NAME" value="Jack" title="" />
    <br /> 
    <br class="clear" />
    <label>
        &nbsp;
    </label>
        <input type="submit" value="Envoyer" />
        <input name="WF" type="hidden" id="WF" value="WF2" />
    </fieldset>
</form>

Thanks for your help...

Chris

4
  • You shouldn't use all-caps in any attribute value, or tags for that matter. Also, you need to be clearer on what you mean by replace all input titles value. Do you want this to happen when the submit button is clicked, or when the input's value changes? Commented Sep 5, 2011 at 21:31
  • you shouldn't just place an order to have some code done for you. Tell us what you have tried show some example code. What errors are you getting. Why do you think you are getting them. If you want something just... done for you, I recommend a freelance site Commented Sep 5, 2011 at 21:35
  • When the page load (sorry for missing that) Commented Sep 5, 2011 at 21:36
  • @austinbv : OK next time I will put the code I tried to use Commented Sep 5, 2011 at 21:47

1 Answer 1

2

Try this

$("input, textarea").each(function(){
    $(this).attr("title", this.value);
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.