Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JS prompt pop-up

Status
Not open for further replies.

atsea

Technical User
Feb 27, 2005
51
JP
Alright,

so I have the prompt box working almost exacly the way I want. There is one more thing I would like to accomplish.

Currently I have somthing like this:

Code:
<script>
function javascript_prompt() {
    
    //two arguments are required for "prompt" boxes
    var message = "Please enter you Name";
    //the default value for the text
    var textBox = "";

    var user_value = prompt(message,textBox);

    // check if there is a value to return
    if (user_value != null) {
        //if ok do this
        attention = document.getElementById('attn');   
        attention.innerHTML = user_value;
          
    } else {
        //if "cancel" do this
        return null;
    }
}
</script>

<div onClick="javascript_prompt()">JavaScript Popup</div>

<div id="attn">THIS IS THE DESTINATION DIV</div>

I would like; var textBox = <to whatever is inside the destination div>

so in the above example when the user first opens the prompt box, the value in the text area is "THIS IS THE DESTINATION DIV".

I'm assuming this will have to first get the element by Id and then read the innerHTML...not sure how to o about this. Any suggestions?

Thanks

atSea
 
var textBox = document.getElementById("attn").innerHTML

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top