JavaScript - Calling Window Alert In Javascript To Html Body
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <script language="Javascript" type="text/javascript"> function user_prompt() { alert.("Hello there"); } user_prompt(); </script> </head> <body> </body> </html> I am such a noob. But I am so bad I cannot even get a window alert to pop up. All I want to do is call the function in the body. But do not know how... Similar TutorialsI have a function which I placed in the header of my html file: Code: <script language="javascript" type="text/javascript"> function UngreyInstallButtons() { document.form1.viewbutton1.disabled = false; document.form2.viewbutton2.disabled = false; document.form3.viewbutton3.disabled = false; } </script> I want to call this from within the body of my html page: Code: <SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript"> <!-- var name = GetCookie('COOKIENAME'); if (name != null) { alert("I GET HERE" + name + "!"); UngreyInstallButtons(); alert("I DONT MAKE IT HERE"); } //--> </SCRIPT> The GetCookie func works and returns name correctly. The first alert() box is displayed, - the second one isn't! It does not come back from the call to UngreyInstallButtons() Why? I also tried this: Code: if (name != null) { alert("I GET HERE" + name + "!"); document.form1.viewbutton1.disabled = false; document.form2.viewbutton2.disabled = false; document.form3.viewbutton3.disabled = false; alert("I DONT MAKE IT HERE"); } Again, it does not execute the = false lines at all. Perhaps I'm missing something obvious? (I am new to js) is there a way in HTML or Javascript to open a new tab (or new window) and force it to be a new tab (or new window) after alert confirmation of javascript? onclick="window.open('google.com', '_blank'); return false;" OR document.location.href = "google.com"+"&target='_blank'"; not working Code: <?php if ($_POST[oke]) { ?> <script language="JavaScript">alert('thanks'); document.location='google.com' </script> <?php } ?> <form target="_self" method="post"> <input type="submit" name="oke" value="save"> </form> how to put the target _blank hi i am having an issue with javascript on my web site. i am a complete noob at this. the objective is to have the page pop up an alert any time the submit button is pressed: 1st if there is no name on the form the alert says "please enter you first name" and returns a false value to the from 2nd if there is a name on the form the alert is supposed to have a thank you message my problem is that it doesn't show the alert when there is a name here is the code Code: <head> <script type="text/javascript> function write(person) { alert("Thank you for conacting us, "+person+"!"); } function formgo() { var name=document.getElementById('namein').value; if (name==null || name=="") { alert("Please enter your name"); return false; } writety(name); document.forms('contact').reset(); } </script> </head> <body> <form> <fieldset id="contactinfo"> <legend>Contact Details</legend> <label> Name <input type="text" name="name" id="namein" placeholder="First and Last name" /> </label> </fieldset> <fieldset id="submitbox"> <input type="submit" id="submit" value="Submit" onclick='formgo()' /> </fieldset> </form> </body> please reply or email me thank you -misstam Hi, How can i call a javascript alert function from an if condition in PHP? For instance: if (A == B) { CALL alert(); } thanks Hi I'm New to javascript how to Call WCF service using Javascript or Jquery in html page.(with out using Activex Objects) Hi, I am creating a new child air window called "test.html" as follow. How can I call a javascript function in parent window from child window? function createMyWindow() { var options = new air.NativeWindowInitOptions(); options.type = air.NativeWindowType.LIGHTWEIGHT; options.systemChrome = air.NativeWindowSystemChrome.NONE; options.transparent = true; mywindow = air.HTMLLoader.createRootWindow(false, options, false); mywindow.load(new air.URLRequest("test.html")); .... } Thanks, ASM I am trying to get the total of the checkboxes selected when the user clicks the "calculate total" button. It isn't working though. What am I doing wrong? Code: <html> <head> <script type="text/javascript"> function calculate(f) { var nums = f.num; var ntext = f.numtext; var nitem = f.numitem; var result = 0; var items = ''; for(var i=0;i<nums.length;i++) { if(nums[i].checked) { result+=parseFloat(ntext[i].value); items+=nitem[i].value+'\n'; } } f.answer.value=result; } if (nums[i].checked) { window.alert("Your total is " + f.answer.value=result;); } </script> </head> <body> <style type="text/css"> .box1 { float:left; width:500px; clear:left; } .box2 { float:left; padding-left:50px; } </style> <form name="myform"> Build your own family meal<br> <div class="box1"> <input type="checkbox" name="num" onclick="calculate(this.form)"> <input type="hidden" name="numtext" value="24.00" onchange="calculate(this.form)"> <input type="hidden" name="numitem" value="pencil" onchange="calculate(this.form)"> <div class="box2">Chicken Enchiladas $24.00</div> </div><br> <div class="box1"> <input type="checkbox" name="num" onclick="calculate(this.form)"> <input type="hidden" name="numtext" value="15.00" onchange="calculate(this.form)"> <input type="hidden" name="numitem" value="pen" onchange="calculate(this.form)"> <div class="box2">Rice and Beans $15.00</div> </div><br> <div class="box1"> <input type="checkbox" name="num" onclick="calculate(this.form)"> <input type="hidden" name="numtext" value="6.00" onchange="calculate(this.form)"> <input type="hidden" name="numitem" value="paper" onchange="calculate(this.form)"> <div class="box2">Chips and Salsa $6.00</div> </div><br> <div class="box1"> <input type="submit" name="answer" value="Calculate Total" onclick="calculate(f)" /> </div> </form> </body> </html> Hello- I wish to not have an alert box, but if I remove the alert the function after the alert doesn't fire. Not sure what the issue could be, so if any js gurus out there can lend any assists, it would be most appreciated. Thanks. Alex- Code: function showPrintView(view){ var win2; win2 = window.open("trans?print=true","Window2","width=600,height=600,scrollbars=yes"); if(view=='1') {win2.alert('Preview'); win2.showView1(); } if(view=='2') {win2.alert('Preview'); win2.showView2();} if(view=='3') {win2.alert('Preview'); win2.showView3();} }; Hi this is my first post i dont know were to post it any way hope you can help me out ok the thing is that i got this script <script> alert("mesages"); document.location = "http://google.com"; </script> easy script but when you click button it takes you the the URL but i want it in a new tab plz help and sorry if this was posted in a new section i try google this but not luck Hi, I need to display alert when I close the browser window. Now I am using the following code to display the alert. But the alert is getting displayed even I click on any links. But the alert should not displayed when i click the link. If you have any solution, please let me know. Thanks in advance. This is my code: <HTML> <head> <script> function closeIt() { return ""; } window.onbeforeunload = closeIt; </script> </head> <body> <a href="http://www.test.com">Click here to navigate to www.test.com</a> </body> </html> Hi everyone. New programmer here trying to get fix this one specific issue I am having and I could use some help. Using Javascript, ASP.net with C# code behind. I am validating a textbox using the onblur event. It is being validated in that it must have an alphanumeric entry before the user tabs off of it to the next box. The validation part works, the part that doesn't work is that I get the validation alert textbox if I close the window. I have a workaround in that I am assigning that textbox a character using windo.onberforeunload but I know that isn't right. Here is what I have so far... Code behind on Page_Load... Code: txtCLBRTNWC.Attributes.Add("onblur", "return reqVLD(this)"); here is my textbox field... Code: <asp:TextBox ID="txtCLBRTNWC" runat="server" Width="75" MaxLength="4" ontextchanged="txtCLBRTNWC_TextChanged" TabIndex="1" onkeyup="clbwclngCHK(this);" ></asp:TextBox> And here are the 2 functions being used... Code: function reqVLD(alphanumericChar) { var chk = /^[a-zA-Z0-9]+$/; // var boxid = document.getElementById("<%=txtCLBRTNWC.ClientID%>").value; // var matchArray = boxid.match(chk); if(document.getElementById("<%=txtCLBRTNWC.ClientID%>").value.match(chk)) { return true; } else { document.getElementById("<%=txtCLBRTNWC.ClientID%>").focus(); document.getElementById("<%=txtCLBRTNWC.ClientID%>").value = ""; alert("Please enter a Work Center."); return false; } } function clbwclngCHK(obj_in)//When txtCLBRTNWC entry hits the max of 4 auto focuses to next box. { if (obj_in.value.length == 4) document.getElementById("<%=txtSTRTDT.ClientID%>").focus(); } Here is my work around... Code: window.onbeforeunload = function () { document.getElementById("<%=txtCLBRTNWC.ClientID%>").value = "1"; } Summary. User has to enter something in box before they can move on. This is checked and validating using an onblur event. Problem is, the onblur event fires if closing\exiting the window. I know there has to be a better way of doing this. Any advise or help would be greatly appreciated. Thanks Will Hello everyone~ I hope this will be a very simple question for someone on here. I am a current web design/development major at the art institute kansas city, and this has stumped me and my teacher pretty hard... I am trying to implement the window widget javascript like the one found he http://www.dynamicdrive.com/dynamicindex8/dhtmlwindow/ Where it looks like windows are opening up on the web page. It gave some fairly specific directions: upload these two files to your server and add these tags to create the functions that are called from the linked files. It sounded fairly simple. I uploaded and linked the two files from my server to the test page I was making, and then created my code and my links (the links call on the code to call on the linked script to open the window with your information.) However, somewhere in the midst of there, something isn't working and I can't figure out what. When I click the link on the test page, instead of opening a window, the link opens with a # in the URL bar after the web address. You can see what I'm talking about he http://zero7starz.com/test/home.html and see the source code and everything. The files that are in my "test" directory are the two files I needed linked, the home.html file, and the file I'm trying to call "Lingo.html". Can anyone on here see what the issue is? Or any other information you need from me I'll be happy to provide, but I wasn't sure what else I needed to include in here besides my source code. Much appreciated! -Jay Here is the program: http://www.1728.com/newwindow.htm Basically, I want to input a number in the input box, which assigns a number to the variable numval located at document.box1.b1. When clicking on the "new window" button, an alert displays the input box value, then another window opens and displays the integers 1 through 12 and the amount squared. I would like the new window to obtain the number from the previous window so that the new window will display integers (and their squares) from 1 to the value of numval. Hi I have create a website where many features do not support IE versions, Can someone help me on javascript code that can alert the user to use Netscape to access my website.. I mean Javscript alert code that will recommend the user to use netscape to access my website .. Any help will be much appreciated Hi Guy's, Hope I'm posting in right forum I haven't been here for years I have a program that allows us to insert an alert box on our website triggered by the no right click....... Now we just insert text because the program allows us to but I want to use "&" this is going into a Javascript and it comes out as "&" I know JS uses ampersand I have tried all methods of putting this in but just get & etc...... Any chance someone knows otherwise plz?? Frank I'm still new to javascript.. My question: How and where do I add an alert that comes up to make sure the user answers all questions before the pop-up window comes up to display score and answers? Here is a link to the quiz Thanks sooo much!! Below is the code.. Code: <script language="javascript" type="text/javascript"> var done = new Array; var yourAns = new Array; var score = 0; function getRBtnName(GrpName) { var sel = document.getElementsByName(GrpName); var fnd = -1; var str = ''; for (var i=0; i<sel.length; i++) { if (sel[i].checked == true) { str = sel[i].value; fnd = i; } } // return fnd; // return option index of selection // comment out next line if option index used in line above return str; } function StatusAllCheckboxes(IDS,cnt) { var str = ''; IDS = 'q'+IDS; var tmp = ''; for (var i=0; i<cnt; i++) { tmp = document.getElementById(IDS+'_'+i); if (tmp.checked) { str += tmp.value + '|'; } } return str; } // function Engine(question, answer, opt, Qtype) { function Engine(question, answer, Qtype) { switch (Qtype) { case "RB" : yourAns[question] = answer; break; case "SB" : yourAns[question] = answer; break; default : yourAns[question] = ''; alert('Invalid question type: '+Qtype); break; } } function EngineCB(question, answer, itemcnt) { // answer is not used at this time yourAns[question] = StatusAllCheckboxes(question,itemcnt); // alert('question: '+question+' :'+yourAns[question]); } //This is the code that calculates the score. function Score(){ score = 0; var tmp = ''; var answerText = "Quiz Results<p>"; // alert('Size of QR: '+QR.length); for (var i=1; i<QR.length; i++) { answerText = answerText+"<br>Question :"+i+" Your answer: "+yourAns[i]+"<br>"; tmp = QR[i][3]; if (QR[i][0] == 'CB') { tmp = tmp+'|'; } // alert(i+' : '+tmp+' : '+yourAns[i]+'\n\n'+answerText+'\n\n'); if (tmp != yourAns[i]) { answerText = answerText+"<br>The correct answer was "+QR[i][3]+"<br>"+explainAnswer[i]+"<br>"; } else { answerText = answerText+" <br>You got this one right! <br>"; score++; } } answerText=answerText+"<br><br>Your total score is : "+score+" out of "+(QR.length-1)+"<br>"; // for varying number of questions, alter scoring var ScoreMax = QR.length-1; var ScoreInc = Math.floor(ScoreMax / 12); // Don't have fewer than 5 questions. answerText=answerText+"<br>Comment : "; if(score<=ScoreInc){ answerText=answerText+"Not quite."; } if(score>=(ScoreInc+1) && score <=(ScoreInc*2)){ answerText=answerText+"Try Again!."; } if(score>=(ScoreInc*2+1) && score <=(ScoreInc*3)){ answerText=answerText+"Rats!."; } if(score>=(ScoreInc*3+1) && score <=(ScoreInc*4)){ answerText=answerText+"Maybe better next time"; } if(score>=(ScoreInc*4+1) && score <=(ScoreInc*5)){ answerText=answerText+"Try Again!"; } if(score>=(ScoreInc*5+1) && score <=(ScoreInc*6)){ answerText=answerText+"I bet you can do better!"; } if(score>=(ScoreInc*6+1) && score <=(ScoreInc*7)){ answerText=answerText+"Hey, pretty good job!"; } if(score>=(ScoreInc*7+1) && score <=(ScoreInc*8)){ answerText=answerText+"You almost got it!"; } if(score>=(ScoreInc*8+1) && score <=(ScoreInc*9)){ answerText=answerText+"Pretty Good! "; } if(score>=(ScoreInc*9+1) && score <=(ScoreInc*10)){ answerText=answerText+"Almost! You can do it!"; } if(score>(ScoreInc*11+1)){ answerText=answerText+"You did GREAT! Congratulations."; } var w = window.open('', '', 'height=500,width=750,scrollbars'); w.document.open(); w.document.write(answerText); w.document.close(); } </script> Code: <form name="myform" class="quiz"> <ol> <script type="text/javascript"> var str = ''; var tmpr = []; var resp = ['True','False']; // allows for up to 10 responses (can have more) for (q=1; q<QR.length; q++) { str += '<li class="quiz">'+QR[q][1]+'</li><br />'; tmpr = QR[q][2].split('|'); switch (QR[q][0]) { case 'RB' : for (var r=0; r<tmpr.length; r++) { str += '<input type="radio" name="q'+q+'" value="'+resp[r]+'"'; str += ' onClick="Engine('+q+',this.value,\''+QR[q][0]+'\')">'; str += ' '+tmpr[r]+'<br />'; } break; case 'CB' : for (var r=0; r<tmpr.length; r++) { str += '<input type="checkbox" id="q'+q+'_'+r+'" name="q'+q+'" value="'+resp[r]+'"'; str += ' onClick="EngineCB('+q+',this.value,'+tmpr.length+')">'; str += resp[r]+' '+tmpr[r]+'<br />'; } break; case 'SB' : str += '<select name="q'+q+'" size="1" id="q'+q+'"'; str += ' onClick="Engine('+q+',this.value,\''+QR[q][0]+'\')">'; for (var r=0; r<tmpr.length; r++) { str += '<option value="'+resp[r]+'">'; str += tmpr[r]+'</option>'; } str += '</select>'; break; /* test code for future entries -- not implemented yet case 'CBM' : break; case 'SBM' : str += '<select name="q'+q+'" size="1" id="q'+q+'"'; str += ' onClick="Engine('+q+',this.value,\''+QR[q][0]+'\')" multiple>'; for (var r=0; r<tmpr.length; r++) { str += '<option name="q'+q+'" value="'+resp[r]+'">'; str += tmpr[r]+'</option>'; } str += '</select>'; break; */ default : str += q+': Invalid type: '+QR[q][0]; break; } str += "<p />"; } document.write(str); </script> <br /> <br /> <input type=button onClick="Score()" value="How did I do?"> </ol> </form> Hi everyone. I need a Javascript code for the following: i have a checkbox on my page. when this checkbox got checked, an alert like "Are u sure?" must ask if OK or Cancel. if i click OK the checkbox becomes checked, it runs a javascript function (chkIt() )and refreshes the page. if i click Cancel the checkbox should not became checked and my function will not run. Thanks a lot. Hi, I'm not too familiar with javascript but I am trying to find a script which I can enter a specific time and date and when that date is reached the script will alert me with a desired message. (not looking for a calendar) Help would be appreciated Harry Hi I'm making a php/html page and using javascript to keep a count for me. Code: <script type="text/javascript"> var i=0; }</script> . . . <form action="index.php" method="GET"> <input name="game_button" id="guess1" type = "submit" name="1" value="1" style="height: 50; width: 50; font-size: 16" onClick = "i=i+1;"/> </form> <input type="button" onClick = "alert(i);"/> The last button is just a test button, which will tell me what the value of "i" is, but I'm not getting anything when I cllick that button. However if I change the onClick from alert(i), to alert('i') it will alert me a string, so I know the javascript is working. Any ideas? What i am trying to do is to make a system on my website that will grab Data from one or two different divs on one page and have it post it in an alert box on the homepage. http://killerz297.webs.com/events.html on that page i would like to be able to have javascript automatically grab the text from the description and paste it into the red box on this page: http://killerz297.webs.com/index.html what i have so far is on this page in the red box i have a script that countsdown how long until the event is away from the set time i put in it until the event starts at a set time it shows the event description, and then while the event is going on it says event in session, then after the event is over it says event no longer ongoing. but then i have to edit the script to the next event. I would like javascript, or what ever type of code it would take to do this to automatically grab the information. I would like for it to automatically switch the information to the next line when the current event is over and start a countdown from there. This is a lot of coding to do but i just am not THAT familiar with how to write javascript to do this myself. One other thing i would likkeeeee is for the red box on home page to disappear until it is 24 hours until next event, and then automatically close 1 hour after event gets over. Not a big deal if i can't get this but i would love it if someone could. okay finally, that is about it lol. If someone could help me with this i would appreciate it soo soo much! Thanks, hope someone could help me. |