|
I have no idea what environment you are using to test your script with, so I'd suggest that you write out the value of webbrowser so you can see what it contains. Then you can see what it contains. I'd also consider, if I were you, looking at substrings rather than attempting a whole match. For instance, you can get your entire Blackberry tests down to:
if (webbrowser.indexOf("BlackBerry") != -1)
{
document.write("Thanks for viewing ....");
} In future, could you please put blocks of code inside the <pre> tags? It makes it easier to read and is a standard here on CP - just choose the code block option above the textbox.
BTW - if you want to step into your code, make sure that debugging is enabled on your browser, and put a debugger; statement in there to force a hard break.
|
|
|
|
|
Oh sorry about the code block, I chose inline code...
Does this:
if (webbrowser.indexOf("BlackBerry") != -1)
{
document.write("Thanks for viewing ....");
}
Detect every BlackBerry that may view the website?
|
|
|
|
|
Sorry for the double post, but I haven't received a reply in a while. Any help would be appreciated.
|
|
|
|
|
hi ...
i m trying to make this me first simple AJAX example using PHP that shows message from PHP on clicking Button in HTML page .... but this case some prolem ... that is when click on button to show message then nothing is happen .... is also check WAMP ... so any idea or suggestion !!!!
HTML CODE IS,
<!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>MyFirstAJAXProram</title>
</head>
<body>
<script type="text/javascript">
function JavaFunction() {
var xmlhttp;
if(window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
} else {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function() {
if(xmlhttp.readystate == 4) {
document.timerForm.time.value = xmlhttp.responseText;
}
}
xmlhttp.open("GET", "phpfile.php", true);
xmlhttp.send(null);
}
</script>
<form name="timerForm">
<input type="button" onclick="JavaFunction()"; />
Time: <input type="text" id="timer" name="time" value="00:00:00" readonly="readonly" />
</form>
</body>
</html>
PHP CODE;
<!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>
</head>
<body>
<?
echo("KHURRAM SHAHZAD");
?>
</body>
</html>
I found one another problem is that php file also not run when i try to run it directly.....
|
|
|
|
|
|
he just mentioned running a php directly.
Solution:
1) Even though WAMP is installed on ur system, it might not be configured properly, refer to the prev post
2) You are running files from the folder. instead, add "Listen 127.0.0.1:80" in ur httpd.conf (apache config file), then open any browser and type "localhost" in address and hit enter.
also rename the html file to index.html so it is served to the browser without and explicit input.
3) "I ran php directly" is the fastest way to achieve defame on any php forum..
also, a starter tip: never use short php tag ("<?"). use <?php ?>, i learnt this the hard way :/
-- Modified Saturday, October 23, 2010 5:21 PM
|
|
|
|
|
if(xmlhttp.readystate == 4 && xmlhttp.status==200) {
document.timerForm.time.value = xmlhttp.responseText;
}
may be you lost the xmlhttp.status==200.
moocr.com
|
|
|
|
|
Hi, I'm having a problem retrieving a data from an access database and put it into a textbox. I tried to code it but it didn't worked. here's my code:
function search()
{
try{
var connection = new ActiveXObject("ADODB.Connection");
var rs = new ActiveXObject("ADODB.Recordset");
connection.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\\IT114P\\Week2-Hibaler\\regform.mdb");
rs.Open("select emailAddress from RegFormTable where emailAddress = '"+document.regpage.emaildelete.value+"';", connection);
rs.MoveFirst;
while(!rs.eof)
{
document.regpage.email.value = rs.fields(0);
rs.MoveNext;
}
rs.close;
conec
}
catch(e)
{
alert(e);
}
}
When I use this code I always get an ObjectError message. I don't know where or what's the problem with the code. Can anyone help me?
|
|
|
|
|
Is there an "E" drive on the client? This won't work when the database is on a server.
You might also take note that JavaScript can be downloaded and opened by anyone in the same way that one downloads HTML. That means that other people can see your connectionstring and open the database/make changes as they see fit.
I are Troll
|
|
|
|
|
I have an code that i use to retrive data from access DB and to show into textbox.
<%
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:OBS","","");
} catch(Exception e) { out.println(e);}
if(con!=null) {
try {
Statement statement = con.createStatement();
ResultSet rs = statement.executeQuery("SELECT * from userform where srno='"+id+"'");
while(rs.next()) {
n=n+1;
%>
<input type="text" name="fname" value="<%=rs.getString(2)%>" width="15" />
|
|
|
|
|
Unless you run the web application locally on the client I would avoid using Javascript to access any database. If the application is not running locally, try ASP.Net as an alternative and run the database on the server.
V.
|
|
|
|
|
Hi,
The below code works well without placing master pages.
ListBox-lst_Siblling
Up button:btn_Up
OnClientClick="MoveUp();return false;"
I want the same code working with master page.
<script language="javascript" type="text/javascript">
function MoveUp() {
var con = document.getElementById("lst_Siblling");
var up = document.getElementById("hid_Up");
up.value = "";
if (con.selectedIndex >= 0) {
alert("HAI");
for (var count = 1; count < con.options.length; count++) {
if (con.options[count].selected == true) {
alert("INSIDE");
var tem = con.options[count].text;
con.options[count].text = con.options[count - 1].text;
alert(parseInt(con.options.length));
up.value = parseInt(con.options.length) - 1;
alert(up.value);
if (con.options[count - 1].selected == false) {
con.options[count].selected = false;
}
con.options[count - 1].selected = true;
con.options[count - 1].text = tem;
}
}
}
else {
alert('Select any item');
}
}
function MoveDown() {
var con = document.getElementById("lst_Siblling");
var selvalue;
var up = document.getElementById("hid_Up");
up.value = "";
if (con.selectedIndex >= 0) {
for (var count = con.options.length - 2; count >= 0; count--) {
if (con.options[count].selected == true) {
var tem = con.options[count].text;
con.options[count].text = con.options[count + 1].text;
selvalue = parseInt(con.options[count].value) + 1;
up.value = selvalue;
alert(up.value);
if (con.options[count + 1].selected == false) {
con.options[count].selected = false;
}
con.options[count + 1].selected = true;
con.options[count + 1].text = tem;
}
}
}
else {
alert('Select any item');
}
}
</script>
Guhananth.S
|
|
|
|
|
Master page has nothing to do with whether the javascript will work or not. What problems are you experiencing? What have you done to debug it?
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
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
|
|
|
|