0

I have a problem with my coding

I am trying to have a prompt box that would ask for name phone and address.

After entering all of the information a button will be clicked and will show all the information entered.

heres my code so far:

    function openNewName()
    {
    var nm=prompt("Name");
    var ph=prompt("Phone Number")
    var add=prompt("Address")
    }

    function openNewNameInfo()
    {
    myWindow=window.open('','','width=300,height=150,top=200,left=500');
    myWindow.document.write(nm + ph + add);
    }

So I need help with this part : myWindow.document.write(nm + ph + add);

Please I need help! Thanks!

user2132849
  • 81
  • 1
  • 1
  • 2
  • Try look at this answer: [link] http://stackoverflow.com/questions/10472927/add-content-to-a-new-open-window – Atep Mar 04 '13 at 23:25

1 Answers1

0

You'd do that like so:

function openNewName() {
    var nm = prompt("Name");
    var ph = prompt("Phone Number");
    var add = prompt("Address");
    if (add) openNewNameInfo(nm, ph, add); //you could check for more values here
}

function openNewNameInfo(nm, ph, add) {
    myWindow = window.open('', '', 'width=300,height=150,top=200,left=500');
    myWindow.document.write("name : " +nm + "<br>Phone : "+ ph + "<br>Adress : " + add);
}

openNewName();

FIDDLE

adeneo
  • 312,895
  • 29
  • 395
  • 388