JS confirm usage, line change and parameter detailed

Source: Internet
Author: User

Usage: Confirm (< string >); pop up a dialog box with OK and Cancel buttons, display < string > content, ask the user to make a choice, the entire document read, Script run will be paused. Returns a true value if the user presses OK, and returns a value of False if "cancel" is pressed.

if (Confirm ("confirm submission"))
{
}

Instance

<a href= "Web effects: if (Confirm (' Confirm deletion? ')) window.location= ' del.asp Tutorial ' > Delete </a>


Of course, you can write confirm in a function.

<script language= "JavaScript" >
function Confirmdel (str) {
return confirm (str);
}
</script>
<a href= "delete.asp" onclick= "return Confirmdel (' OK to delete ')" > Delete </a>

Confirm Line Change

<script>
function Checkadspos (Pos) {
if (Pos!=0) {
var msg = document.getElementById ("confirmmsg" +pos). Value;
msg = Msg.replace ("n", String.fromCharCode (10));
Confirm (msg);
var msg = document.getElementById ("CONFIRMMSG1"). Value;
Alert ("N". charCodeAt ());
Alert (String.fromCharCode (10));
Alert (document.getElementById ("CONFIRMMSG1"). Value.charcodeat ())
}
}
</script>
<input id= "CONFIRMMSG1" type= "hidden" value= "n" >
<input id= "CONFIRMMSG2" type= hidden "value=" You??? The 2nd line. N. Line ">
<input id= "CONFIRMMSG3" type= hidden "value=" You??? The 3rd line. N. Line ">
<input id= "ConfirmMsg4" type= hidden "value=" You??? The 4th line. N. Line ">
<input id= "ConfirmMsg5" type= hidden "value=" You??? The 5th line. N. Line ">
<input id= "ConfirmMsg6" type= hidden "value=" You??? the 6th line. N. Line ">
<input id= "ConfirmMsg7" type= hidden "value=" You??? The 7th line. N. Line ">
<input id= "ConfirmMsg8" type= hidden "value=" You??? The 8th line. N. Line ">
<select name= "Adspos" size= "1" "id=" Adspos "onchange=" return Checkadspos (This.options[this.selectedindex].value); " >
<option value= "0" SELECT&GT; </option>
<option value= "1" > Line 1th </option>
<option value= "2" > Line 2nd </option>
<option value= "3" > Line 3rd </option>
<option value= "4" > Line 4th </option>
<option value= "5" > Line 5th </option>
<option value= "6" > Line 6th </option>
<option value= "7" > Line 7th </option>
<option value= "8" > Line 8th </option>
</select>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.