Hi all, as a noob to javascript I am trying to find a way to add an extra piece of hidden text onto the end of the text a user enters into the form field so that when the form is sent the extra text will automatically be added to the end before sending.

I have tried cobbling together different scripts using onblur/onclick etc but I just cannot get any to work as I need..

You should do the following:

- Create a function that needs one argument, which is the id of the input.

- The function retrieves the value using document.getElementById(id) and then adds the part of text you want on the end.

- Then you update the value of the input with the one with the text on the end.

- The function should be called using the event onsubmit="return function()" in the <form> tag


A small start:

function addText(id) {
var text = document.getElementById(id).value;

// Here comes the rest of the code...

return true;
}

~G

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.