HTML - Need Help In Executing This Simple Java Script Program
Hello,
I got a program, but I am unable to execute it, the addition of two variables is not executing in the output, I am unable to find the mistake in the program, plz any one find it and let me know the mistake.. Here is the Program ***************************** <!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=iso-8859-1" /> <title>Untitled Document</title> </head> <script type="text/javascript"> var firstnum,secondnum,num1,num2,sum; fistnum = window.prompt("enter the first number","0"); secondnum = window.prompt("enter the second number","0"); num1 = parseint( firstnum ); num2 = parseint( secondnum ); sum = num1 + num2; document.writeln("<h1> the sum is "+ sum + "</h1>"); </script> <body> <p> Click Refresh (or Reload) to Run the script once again </p> <!-- <input name="submit" type="button" onclick="document.writeln();"--> </body> </html> *********************** Similar TutorialsHello guys, I am new to this forum, yesterday i started learning html and i am writing sample codes for different things and i got an error when i tried to hyper linking to the link on the same page. i tried to create 5 hypers links within the page and wrote the syntax and all correctly ..but when i tried to click the first one and the second one its working but when i tried with the 3rd, 4th and 5th hyper links its not getting linked to the correct place... http://personalpage.webng.com/lists.html .this is the webpage i wrote... when i click the first two they are linked to the correct place but when i tried the others they are not getting linked properly...... can anyone see the program and tell me whats the solution?\ thankyou Hi. I am creating web service. But the problem must be somewhere on HTML page. When I submit form, the data send by web service (java program) to the page does not show up. If I do not submit form, then the program works; results appear on the page. The form is submitted invoking pushSubmit() javascript function. This method is invoked from setMessage() javascript function. I submit form cause in this way I discover what value is selected on drop down list. This is done using JSP code. Can I do it somehow else. Next action using retrieved data is to invoke Java class on server side. What might be the problem? This is the code: Code: <%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" pageEncoding="UTF-8" %> <%@ page import="mart.ebay.database.ReadsCategoryTable" %> <jsp:useBean id="categoryList" class="mart.ebay.database.ReadsCategoryTable" scope="request" /> <jsp:setProperty name="categoryList" property="*"/> <!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>eMart</title> </head> <body class="create"> <!-- shows items from that country by default --> <% // String strSiteId = "EBAY-GB"; // Object categoryList = session.getAttribute("items"); // receives result from servlet // out.println(categoryList + " result ++++++++++++++++++++++++++++"); // strSiteId = (String)session.getAttribute("siteId"); // strSiteId =(strSiteId == null)? "": strSiteId; // out.println(strSiteId+ " strSiteId +++++++++++++++"); %> <% String result= ""; String strSiteId = request.getParameter("siteId"); strSiteId =(strSiteId == null)? "": strSiteId; if(strSiteId.equals("")) { out.println(strSiteId+ " global ID is empty"); result= categoryList.readTable("EBAY-GB"); } else { out.println(strSiteId+ " this is global ID"); result= categoryList.readTable(strSiteId); } %> <div id="container"> <div id="header"> <h1>Header</h1> <!-- end of header--> </div> <div id="mainContent"> <h1>Main content</h1> <!-- onsubmit="run()" --> <form name="form" id="form1" action="index.jsp" method="post" > <table id="input" border="0" cellpadding="0" cellspacing="5"> <tr> <th align="left">Looking for</th> <th align="left">Location</th> <th align="left">Category</th> </tr> <tr> <td align="left"><label><input style="width: 230px" type="text" name="message" id="message" /></label> </td> <td> <select name="siteId" id="siteId" > <option <%=(strSiteId.equals("EBAY-AT"))?"selected":""%> value="EBAY-AT">Austria</option> <option <%=(strSiteId.equals("EBAY-AU"))?"selected":""%> value="EBAY-AU">Australia</option> <option <%=(strSiteId.equals("EBAY-CH"))?"selected":""%> value="EBAY-CH">Switzerland</option> <option <%=(strSiteId.equals("EBAY-DE"))?"selected":""%> value="EBAY-DE" >Germany</option> <option <%=(strSiteId.equals("EBAY-ES"))?"selected":""%> value="EBAY-ES">Spain</option> <option <%=(strSiteId.equals("EBAY-FR"))?"selected":""%> value="EBAY-FR">France</option> <option <%=(strSiteId.equals("EBAY-FRBE"))?"selected":""%> value="EBAY-FRBE">Belgium (French)</option> <option <%=(strSiteId.equals("EBAY-NLBE"))?"selected":""%> value="EBAY-NLBE">Belgium (Dutch)</option> <option <%=(strSiteId.equals("EBAY-FRCA"))?"selected":""%> value="EBAY-FRCA">Canada (French)</option> <option <%=(strSiteId.equals("EBAY-ENCA"))?"selected":""%> value="EBAY-ENCA" onclick="pushSubmit()" >Canada (English)</option> <option <%=(strSiteId.equals("EBAY-GB"))?"selected":""%> value="EBAY-GB" selected="true">United Kingdom</option> <!-- <option value="EBAY-HK">Hong Kong</option> --> <option <%=(strSiteId.equals("EBAY-IE"))?"selected":""%> value="EBAY-IE" onclick="pushSubmit()" >Ireland</option> <option <%=(strSiteId.equals("EBAY-IN"))?"selected":""%> value="EBAY-IN">India</option> <option <%=(strSiteId.equals("EBAY-IT"))?"selected":""%> value="EBAY-IT">Italy</option> <!-- <option value="EBAY-MOTOR">Motors</option> --> <option <%=(strSiteId.equals("EBAY-NL"))?"selected":""%> value="EBAY-NL">Netherlands</option> <option <%=(strSiteId.equals("EBAY-NLBE"))?"selected":""%> value="EBAY-NLBE">Belgium (Dutch)</option> <option <%=(strSiteId.equals("EBAY-PH"))?"selected":""%> value="EBAY-PH">Philippines</option> <option <%=(strSiteId.equals("EBAY-PL"))?"selected":""%> value="EBAY-PL">Poland</option> <option <%=(strSiteId.equals("EBAY-SG"))?"selected":""%> value="EBAY-SG">Singapore</option> <option <%=(strSiteId.equals("EBAY-SE"))?"selected":""%> value="EBAY-SE">Sweden</option> <option <%=(strSiteId.equals("EBAY-MY"))?"selected":""%> value="EBAY-MY">Malaysia</option> <option <%=(strSiteId.equals("EBAY-US"))?"selected":""%> value="EBAY-US">United States</option> </select> </td> <td> <select name="Category" > <option value="100" ><%= result%></option> </select> </td> <td> <label> <input type="button" value="Start" onclick="run()"/></label></td> </tr> </table> </form> </div> <div id="footer"> <p>Footer</p> </div> <!-- the end of container--></div> <script type="text/javascript"> function getXmlHttpRequest() { try { // Firefox, Opera 8.0+, Safari return new XMLHttpRequest(); } catch (e) { // Internet Explorer try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { alert("Your browser does not support AJAX!"); return null; } } } } function setLocation(location) { strSiteId = location; var xmlHttp = getXmlHttpRequest(); xmlHttp.open("GET","app/messages/location/" + location,true); xmlHttp.send(null); } function setCategory(category) { var xmlHttp = getXmlHttpRequest(); xmlHttp.open("GET","app/messages/category/" + category, true); xmlHttp.send(null); } function setMessage(index) { var xmlHttp = getXmlHttpRequest(); //alert(index) xmlHttp.onreadystatechange=function() { if(xmlHttp.readyState==4) { // document.write(xmlHttp.responseText.indexOf("<body>")); if(xmlHttp.responseText.indexOf("<body>") != -1) { s = xmlHttp.responseText.substring(xmlHttp.responseText.indexOf("<body>") + 6, xmlHttp.responseText.indexOf("</body>")) document.getElementById("output").innerHTML=s; } else { document.getElementById("output").innerHTML=xmlHttp.responseText; } pushSubmit() // submits form } } xmlHttp.open("GET","app/messages/" + index,true); xmlHttp.send(null); } function run(){ setCategory(document.form1.Category.value) setLocation(document.form1.siteId.value) setMessage(document.form1.message.value) alert(document.form1.Category.value+" "+document.form1.siteId.value+ " "+document.form1.message.value) } function pushSubmit() { document.getElementById('form1').submit(); } </script> <% // sessionObj = null; //arlItems = null; //session.removeAttribute("items"); //session.removeAttribute("siteId"); %> <h3>result</h3> <div id="output" style="border: 1px solid black; color: black; height: 18em; width: 100%"></div> </body> </html> _ |_| Diagnostic _ |_| System Restore _ |_| PC Tune Diagnostic ~ To find whats wrong System Restore ~ Restores software to factory defaults PC Tune ~ Performance optimizer -------------------------- My goal is that when a technician checks a box ( one or more of the following above ) an automatic message is added to a separate page that can be printed out. So to say, if I where to check 'diagnostic' and 'pc tune' my internet browser will open a second page with the descriptions of the two services. The more boxes you click the more paragraphs that get added to the second page. How to create explorer like menu in Html or java script? eg + Game(inside this Cricket and Football) when click on + sign it become like-- - Game -Cricket -Football Can anybody suggest me, by which command I can do it? Commercial Removals || Removals and Storage||Specialist Removals Hey folks, I have been looking all over the web for hours looking for the script that potspace.com uses that cool little warning thing. No I do not use potspace.com Some one told me about their pop up notifier thing and I want it for my site however It's just a regular site. I want to use that for Website Alerts. =) I really want that script If some one could please just visit potspace.com as soon as they get to the site a div will pop up I like that it's really cool can some one please get me the script that does that. I thought I made it but I didn't it just stayed on the page 24/7 LOL it didn't have that re'direct back to the page button. Also It only shows up one time per a session.!! I am having trouble trying to create a table that each table cell changes colour on mouseover and mouseout. I have posted my codes so far where I have managed to change the cursor on mouseover and mouseout. Any help would be most appreciated. This is table.html Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <script type="text/javascript" src="/Tests/table.js"></script> </head> <body> test table <table border="1" class="pictures" style="margin-left: 300px" width="300px"> <tr > <td onmouseover="cursor_hand()" onmouseout="cursor_clear()"><p>1</p></td> <td onmouseover="cursor_hand()" onmouseout="cursor_clear()"><p>2</p></td> <td onmouseover="cursor_hand()" onmouseout="cursor_clear()"><p>3</p></td> </tr> <tr> <td onmouseover="cursor_hand()" onmouseout="cursor_clear()"><p>4</p></td> <td onmouseover="cursor_hand()" onmouseout="cursor_clear()"><p>5</p></td> <td onmouseover="cursor_hand()" onmouseout="cursor_clear()"><p>6</p></td> </tr> <tr> <td onmouseover="cursor_hand()" onmouseout="cursor_clear()"><p>7</p></td> <td onmouseover="cursor_hand()" onmouseout="cursor_clear()"><p>8</p></td> <td onmouseover="cursor_hand()" onmouseout="cursor_clear()"><p>9</p></td> </tr> </table> </body> </html> This is table.js Code: function cursor_hand(){ document.body.style.cursor = 'pointer'; } function cursor_clear() { document.body.style.cursor = 'default'; } Which you think i should go with if I am using drop down menus for my site? CSS dropdown or Java? There is a lot of nifty programs out there that generate this dropdown menu for you, but what are the disadvantages? Should I create using CSS in the page itself, which seems more difficult to do and more time consuming... Hi, i am creating a web page dynamically through ajax like this here i am creating a td element and appending a button element to it Code: var td5= document.createElement("TD"); td5.style.whiteSpace = "nowrap"; td5.setAttribute("id", "button" + hostname); var button=document.createElement("input"); button.setAttribute("type", "button"); button.setAttribute("id", "updatebutton" + hostname); button.setAttribute("value", "Click here"); button.setAttribute("onclick", "alert('OK')"); td5.appendChild(button); it appearing good on web page the but when i click the button, where i am not getting supposed alert Code: button.setAttribute("onclick", "alert('OK')"); line is not showing effect and when i try like this Code: button.onclick=new Function (alert('hi')); when my IE loads the page i am getting alert where as , alert must come after clicking the button any work around please Thanks R How can I run HTML from Javascript? What I mean is that from etc. index.html I will load a file.js script, which will include the whole HTML. Not sure if I can explain myself correctly, do you know what I mean? On http://www.thomasmckee.com/scroller.html, how can I align the image of the car to the left of the scroller with no spacing between them and the total size be 960w by 150h? I mean, how do I butt them next to each other? If you can, will you email your answer to thomas@thomasmckee.com? how to fire a event which performs Ctrl + A from java script? Thanks R dear guys: i have a javascript code which shows 10 recent post of my blog by RSS, there is a advertise of that site at the bottom of it, some friend told me to add : <div> tags to it and define width and height for it and for the height change the number until the ad disappears... also he told me to put the flow on "hidden" but i don't understand much can u help me out? here is an example: Code: <script type='text/javascript' src='http://rssReader.com/code.php?t=1&back=_fff&color=_444&box=_fff&max=10&rss=http://sokkan.ir/post/rss/' ></script> I was given some Java Script code to put in an HTML formatted file. The java script will randomly create an image. What I would like to do do is add text and make it so the text starts at the top of the image and not the bottom like it's doing now. In short, I'd like to have the text wrap around the image that the java script creates. Is this possible, and how do I do it? how to make java script (countdown) like rapidsahre/4shared? please...the code..!! to insert in blogger post? Hi, I am basically a complete beginner when it comes to programming, but im trying to learn so I hope someone can help me. (This is an assignment from the university btw). If that matters in any way. I am making a website with different functions. One of them beeing a text box, where you can input a number. And a javascript will square the number for you. The textbox appears as normal on my website, and I think the javascript should be good, but obv if anything is wrong with it please feel free to comment. When I enter the number and press enter, the only thing appering is the raw code of the javascript. Nothing happens basically, so obv im wondering what I have done wrong. Hope someone can help me. So heres the html code: </div> <div id="content"> <fieldset> <legend>Oppgave 1</legend> <form method="get" action="kvadrering.jsp"> <p><input type="text" name="tall"> <input type ="submit" value="send"></p> </form> </fieldset> And heres the javascript: <form> <input type="text" id="input"></input> <script type="int/javascript"> function kvadrering() { var input = document.getElementById("tall").value; var resultat; resultat = Math.pow(input,2); document.write(resultat); } </script> </form> Hope someone can help me=) hiii all, i am making 2 html pages. one is parent window and another is child window but i want, when i click on a link of child window , parent page will load but with diff frame on parent page i am able to reload the parent pag but the same form will appear so how can i load diff form when parent page is reload?? please mention code for both child and parent page and i am using html e\with java script please reply thanks I have next to no experience with HTML, but I'm hoping someone will quickly help me out here. What I'm trying to do is write a small, simple script that will let me reload a link in a window every set amount of seconds. It's not reloading an actual page, but a link that does an action, so it just has to load this link over and over again. Anyone know how to do this? I'm sure there's a very simple way to do it that I don't know and couldn't find. Thanks in advance! Im at the end of my line here, As crazy as this may sound I cant seem to get this to work. All I want to do is have a user input and email address, that will then post, on submit to a email account I have. I have tried (seriously) about 15 different tutorials and even a few already completed codes, and I only got it working once, then I deleted the code my accident... Anyways I need a very basic code that I can input into my page that will enable the above. And yes my server accepts PHP Iv checked and rechecked this, For some reason I just dont seem to get on with PHP. Iv been at this for a week?!? Please im going crazy here, help please.......... Ok, basically here is the run down of what I am looking for this script to do. Code: http://www.thisisjustanexamplesite.com/stats=XXXX-XXXX-XXXX (X's representing numbers) All I want is the webpage to just show a text field and a submit button. So when the user puts in the numbers in the text field and hits submit, it automatically will put the numbers he put into the text field on the end of that link mentioned above and then take them there. I'm thinking it should just be simple HTML but possbily PHP maybe, not sure. Any help would be appreciated! |