Jump to content

prompt box


smiles

Recommended Posts

Here is an example about prompt box of w3schoolshttp://www.w3schools.com/js/tryit.asp?filename=tryjs_promptso after I click on button and fill the gap ... what I write appear on the right page and the button is lost !!!I want it still appear there and what I write appears under it , for example : HelloI again click the button and write " Everybody " in the gap , click OK and what I see in the right is : (The button) Hello Everybody How can I do it ??? :)Thanks !

Link to comment
Share on other sites

add a div tag after the <form> <div id="divdd" ></div>and change the code document.write as divdd.innerText and try to referesh and definetly. All the best:)

Link to comment
Share on other sites

you mean that ?

<html><head><script type="text/javascript">function disp_prompt(){var name=prompt("Please enter your name","")if (name!=null && name!=""){divdd.innerText ("Hello " + name + "! How are you today?")}}</script></head><body><form><div id="divdd" ></div><input type="button" onclick="disp_prompt()" value="Display a prompt box"></form></body></html>
but I don't see it works maybe something you know but I don't know so I can't following your advise exactly :) anyway , thanks :)
Link to comment
Share on other sites

<script type="text/javascript">var name=prompt("What's your name?");document.getElementById("divid").innerHTML="Hello "+name+", how are you today?"</script><div id="divid"></div>

Final code.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...