|
hey plz help me i tried to make o program in which user inputs a number between 1 to 10 and its table appears..but i its not working properly..when i press a number table of 2 prints every time.
plz help me in finding mistake.thnks
<html>
<title> :Tables: </title>
<head>
<script type = "text/javascript">
function disp_promt()
{
}
</script>
</head>
<body>
<h2> TABLES USING FOR LOOP </h2>
<script type = "text/javascript">
var number = prompt("Please enter a number between 2 to 10", "")
if (number=2)
{
for (num=1; num<=10; num++)
{
document.write("2 x " + num + "=" + 2*num + "<br>");
}
}
else if (number=3)
{
for (num=1; num<=10; num++)
{
document.write("3 x " + num + "=" + 3*num + "<br>");
}
}
else if (number=4)
{
for (num=1; num<=10; num++)
{
document.write("4 x " + num + "=" + 4*num + "<br>");
}
}
else if (number=5)
{
for (num=1; num<=10; num++)
{
document.write("5 x " + num + "=" + 5*num + "<br>");
}
}
else if (number=6)
{
for (num=1; num<=10; num++)
{
document.write("6 x " + num + "=" + 6*num + "<br>");
}
}
else if (number=7)
{
for (num=1; num<=10; num++)
{
document.write("7 x " + num + "=" + 7*num + "<br>");
}
}
else if (number=8)
{
for (num=1; num<=10; num++)
{
document.write("8 x " + num + "=" + 8*num + "<br>");
}
}
else if (number=9)
{
for (num=1; num<=10; num++)
{
document.write("9 x " + num + "=" + 9*num + "<br>");
}
}
else if (number=10)
{
for (num=1; num<=10; num++)
{
document.write("10 x " + num + "=" + 10*num + "<br>");
}
}
else
{
document.write("You haven't entered a number between 2 to 10");
}
</script>
</body>
</html>
|
|
|
|
|
replace
if (number=2)
with
if (number==2)
and do the same for all the other if statements 3 through 10.
Alternatively, replace the whole lot with just
var number = prompt("Please enter a number between 2 to 10", "")
for (num=1; num<=10; num++)
{
document.write(number + " x " + num + "=" + number*num + "<br>");
}
|
|
|
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>MULTIPLE TABLE EXAMPLE4 Page</title>
</head>
<body>
<h2>
<:: MULTIPLE TABLE EXAMPLE4 ::>
</h2>
<script type="text/javascript">
var number = prompt("Please enter a number for Multiple-Table :: ","");
var range = prompt("Please enter the Range ::","20");
for (i=1; i<=range; i++)
document.write(number+" x " + i + " = " + (number * i) + "<br>");
</script>
</body>
</html>
|
|
|
|
|
<html>
<title> :Tables: </title>
<head>
<script type = "text/javascript">
function disp_promt()
{
}
</script>
</head>
<body>
<h2> TABLES USING FOR LOOP </h2>
<script type = "text/javascript">
var number = prompt("Please enter a number between 2 to 10","");
switch(number)
{
case '2':
for (num=1; num<=10; num++)
{
document.write("2 x " + num + "=" + 2*num + "<br>");
}
break;
case '3':
for (num=1; num<=10; num++)
{
document.write("3 x " + num + "=" + 3*num + "<br>");
}
break;
case '4':
for (num=1; num<=10; num++)
{
document.write("4 x " + num + "=" + 4*num + "<br>");
}
break;
case '5':
for (num=1; num<=10; num++)
{
document.write("5 x " + num + "=" + 5*num + "<br>");
}
break;
case '6':
for (num=1; num<=10; num++)
{
document.write("6 x " + num + "=" + 6*num + "<br>");
}
break;
case '7':
for (num=1; num<=10; num++)
{
document.write("7 x " + num + "=" + 7*num + "<br>");
}
break;
case '8':
for (num=1; num<=10; num++)
{
document.write("8 x " + num + "=" + 8*num + "<br>");
}
break;
case '9':
for (num=1; num<=10; num++)
{
document.write("9 x " + num + "=" + 9*num + "<br>");
}
break;
case '10':
for (num=1; num<=10; num++)
{
document.write("10 x " + num + "=" + 10*num + "<br>");
}
break;
default:
document.write("You haven't entered a number between 2 to 10");
}
</script>
</body>
</html>
|
|
|
|
|
<html>
<title> :Tables: </title>
<head>
<script type = "text/javascript">
function disp_promt()
{
}
</script>
</head>
<body>
<h2> TABLES USING FOR LOOP </h2>
<script type = "text/javascript">
var number = prompt("Please enter a number between 2 to 10","");
switch(number)
{
case '2':
for (num=1; num<=10; num++)
{
document.write("2 x " + num + "=" + 2*num + "<br>");
}
break;
case '3':
for (num=1; num<=10; num++)
{
document.write("3 x " + num + "=" + 3*num + "<br>");
}
break;
case '4':
for (num=1; num<=10; num++)
{
document.write("4 x " + num + "=" + 4*num + "<br>");
}
break;
case '5':
for (num=1; num<=10; num++)
{
document.write("5 x " + num + "=" + 5*num + "<br>");
}
break;
case '6':
for (num=1; num<=10; num++)
{
document.write("6 x " + num + "=" + 6*num + "<br>");
}
break;
case '7':
for (num=1; num<=10; num++)
{
document.write("7 x " + num + "=" + 7*num + "<br>");
}
break;
case '8':
for (num=1; num<=10; num++)
{
document.write("8 x " + num + "=" + 8*num + "<br>");
}
break;
case '9':
for (num=1; num<=10; num++)
{
document.write("9 x " + num + "=" + 9*num + "<br>");
}
break;
case '10':
for (num=1; num<=10; num++)
{
document.write("10 x " + num + "=" + 10*num + "<br>");
}
break;
default:
document.write("You haven't entered a number between 2 to 10");
} </script>
</body>
</html>
|
|
|
|
|
This code:
var allowedChars = "qwertyuiopasdfghjklzxcvbnm1234567890/'קראטוןםפךלחיעכגדשזסבהנמצ";
var card = document.getElementById("cardid").value;
for (i=0; i< 10; i++)
if (allowedChars.indexOf(card[i]) == -1)
{
alert("Error");
return true;
}
is supposed to check an input string.
For an unknown reason, it works on ff 3.6.10, but not on IE 7.
Help will be highly appreciated.
Thanks,
Summer Bulb.
|
|
|
|
|
I don't think you can use
card[i]
to refernce the i'th character in a string this way, not in IE anyway. Try
card.charAt(i)
instead.
|
|
|
|
|
why you do not use regular expression?
var reg=/[qwertyuiopasdfghjklzxcvbnm1234567890]{10}/gi;
if(!reg.test(document.getElementById("cardId").value)){
alert("Error");
}
see more javascript skill, just click moocr.com
|
|
|
|
|
I have several pages that I open using target="_blank", which all have somekind of functionality in them. When some of these pages close I would like to have the page that made the initial call to do a refresh so that the new data is displayed. Is is possible?
|
|
|
|
|
I am not sure whether this is the best solution. But my 2 cents...
May be you could open those pages as a popup, when the popup is closed a javascript function can be called. Check out the following post for an example http://www.eggheadcafe.com/articles/20060117.asp[^]
I will post if I am able to think of/find a better way...!
Cheers,
Karthik
|
|
|
|
|
I had tried popups, I wanted it to be cleaner and only open new tabs in newer browsers, so that is why I used _blank. That being said, if I have to go back to popups then I guess I will have to go back to them.
|
|
|
|
|
What about this method?
Check out the following page. http://www.rgagnon.com/jsdetails/js-0049.html[^]
You could open the window and maintain a list of handles in an array. And then you could have some kind of javascript that executes using setTimeOut. This script could verify if the current handle is open (i.e. check if handle.closed is true/false) and then refresh the page using window.location.href
Cheers,
Karthik
|
|
|
|
|
If the page that made the initial call is the html page that opened the popup then yes. You could attach a javascript event to notify you when the 'popup' gets closed or unloaded.
For example (page1.html):
<a href="page2.html" target="_blank">Add something</a>
<script>
function onPage2Unload(){
alert('tada');
}
</script>
Then you could have something like this on your page2.html:
<script>
window.onbeforeunload = function() { window.opener.onPage2Unload(); }
</script>
In this setup the page2.html will call the window that opened it (page1.html) and execute the code of onPage2Unload before closing or unloading the document.
|
|
|
|
|
Hi all,
I am using a firefox plug in called Live HTTP Headers.
Right now I am trying to filter only left the URL Address and time.
Can anyone help me?
Then convert it back to XPI format.
Need help in it.
|
|
|
|
|
Is this in any way connected to this[^] question?
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
I want to read the Javascript method body
how could I do this, could u refer me few links
Thanks
SaiNath
|
|
|
|
|
You want to read the code which is inside the {} of function?
sunaSaRa Imdadhusen
+91 99095 44184
+91 02767 284464
|
|
|
|
|
Are you saying you want to read the method body?? I don't see why you would want to do that, but this link might be useful - http://www.breakingpar.com/bkp/home.nsf/0/87256B280015193F87256BF8004D72D6[^]
This one loops through all properties in an object passed and you could modify this method to find out the contents of your function alone. Out of curiosity, if you don't mind, what is this for?
Cheers,
Karthik
|
|
|
|
|
function func(){
alert('1');
}
document.write(func);
try it! moocr.com
|
|
|
|
|
Is it possible to call a method of jar file which is residing in Client side, through java script. this is required to access USB port for testing tool development.
Here is give a simple example to help me with code snippet.
A simple Java program (simple.java) which has two methods GetName() and GetID() which returns string and integer value respectively. which is then converted to jar(simple.jar) and placed in C:\Temp\simple.jar.
Can some one help me in java script code snippet, how to call the jar file inside my html file, and how to access the GetName() and GetID() method.
Note: Simple.jar file will be at client machine and NOT at server side, may be i have to learn how to use plugin to download simple.jar from server to client (will be happy if i get some pointers on this too!)
FYI, I am newbie to javascript.
|
|
|
|
|
if dont consider the safe or you browser allow, you can do it use javascript.
but you'd better dont do this operation.
moocr.com
|
|
|
|
|
Thanks for your reply... at last some one is hearing me !
Well.. I am developing a tool which is very internal to our office.. a web access to one of the hardware which is connected to com port. Got a jar file with the hardware which shall be used to connect the hardware through comport. I dont have the source of the jar file.
So, i am not worrying about the security and whether it is feasible etc.
I would appreciate if some one can give the solution.. for the problem i posted.
There is some guy who developed hardware is giving the jar file.. think he had lot of trust with Java language growth!
|
|
|
|
|
Would really appreciate somebody taking a look at this:
http://www.codeproject.com/Messages/3618419/Newbee-Javascript-ASP-SQL-Lookup-Issue-Please-Help.aspx
Sorry if it's the wrong section, but i'm not sure if it's a problem with the ASP or Javascript.
|
|
|
|
|
The error message you show indicates an error with the ASP code.
It's been so long since I ussd classic ASP that I can't really remember it all now, but two things jump straight out from your code:
Having already set:
set objRS = Server.CreateObject("ADODB.Recordset")
you should not be setting it again on line 18 (where the error is)
set objRs = connString.Execute(mySQL)
So try rwemoving the "set" keyword from that line.
Also.. shouldn't you be closing your database connection at some point..? (That's a rhetoric question btw - you should be!)
Do you really have to use clasic ASP? Move on to .NET if you possibly can.
|
|
|
|
|
Thanks so much for your response, I fully intend on moving into the correct decade with .net, but i'm very new to web development and it's a bit of a learning curve even with ASP & Javascript. I will get there...
I have been through the code as you suggested and i'm still having problems, I simply need an asp recordset into a javascript array. Maybe i'm just too tired, but I just can't get it right.
Message: Object expected
Line: 14
Char: 1
Code: 0
URI: http://localhost/floorfurnishings/autocompleteactive1.asp
Line 14:
objRs_cmd.ActiveConnection = MM_floordb_STRING
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!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">
<!--#include file="Connections/floordb.asp" -->
<%
Dim arrPDFs
Dim javascriptArrayValues
Dim objRs
Dim objRs_cmd
Dim objRs_numRows
Set objRs_cmd = Server.CreateObject ("ADODB.Command")
objRs_cmd.ActiveConnection = MM_floordb_STRING
objRs_cmd.CommandText = "SELECT * FROM dbo.Companies"
objRs_cmd.Prepared = true
Set objRs = objRs_cmd.Execute
objRs_numRows = 0
Function GetPDFsArray()
If NOT objRs.EOF OR NOT objRs.BOF Then
GetPDFsArray = objRs.GetRows()
Else
GetPDFsArray = ""
End If
End Function
'Get array
arrPDFs = GetPDFsArray
If isArray(arrPDFs) Then
for i=0 to uBound(arrPDFs,2)
javascriptArrayValues=javascriptArrayValues & """" & arrPDFs(0,i) & """" & ","
next 'i
javascriptArrayValues=Left(javascriptArrayValues,Len(javascriptArrayValues)-1)
Else
javascriptArrayValues = "Error: No results for array"
End If
%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<%Response.Write(mySQL)%>
<input type="text" name="pdfDesc" id="pdfDesc" autocomplete="off" />
<script>
customarray = new Array(<%=javascriptArrayValues%>);
actb(document.getElementById("pdfDesc"),customarray);
</script>
</head>
<body>
</body>
</html>
<%
objRs.Close()
Set objRs = Nothing
%>
Thanks again.
|
|
|
|