0

I want to add a variable and add something to a functions content.

var variable1;

function myFunction() {
    alert(variable1);
    return variable1;
}

I want to change that to:

var variable1;
var variable2;
function myFunction() {
    alert(variable1);
    alert(variable2);
    return variable1;
}

I want that the changes are applied to a my main html file so that the next time the page is called the changes are in effect.

I already have a Servlet that can produce a new html page but I don't know how to change the JavaScript part of an already existing page.

Edit: so basically I need something like:

 request.getFunction(myFunction).addBeforeReturn(alert(variable2));
7
  • Is the javascript embedded in the html your are producing? Commented Mar 9, 2015 at 12:19
  • 1
    This might help http://stackoverflow.com/a/2413453/2850474 Commented Mar 9, 2015 at 12:22
  • 1
    If you already have the servlet producing HTML content what prevents you from adding few more lines to that code? Commented Mar 9, 2015 at 12:25
  • thx for the answers I edited my question abit to make my point clear. @yellen : yes but I could change that if that is a major problem (quite new to javascript and html) Commented Mar 9, 2015 at 12:44
  • @amarnath thx that tells me how to add a variable, so now I need a way to edit functions Commented Mar 9, 2015 at 12:44

0

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.