JavaScript - Connect Sqlite Database With Js
HI,
Is it possible to connect to a sqlite database via javascript. And I do not mean the HTML 5 Web SQL Database, that is no problem. What I mean is a file-based SQLite database, which is in the same folder as the HTML page.Also, I can not use something like Google's API, only the javascript libraries I can then put in this folder. THX Helge Similar TutorialsHello Everyone, I am using Javascript in ASP page to connect to the database. I am not able to figure out where is the problem. Gettting this error-> Quote: Error Type: Microsoft OLE DB Provider for SQL Server (0x80004005) [DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied. /MyWeb/test.asp, line 9 My code is-> Code: <%@ Language = JavaScript %> <% var myconnection var myrecordset var connectionString myconnection = Server.CreateObject("adodb.connection") connectionString = "Provider=SQLOLEDB.1;Password=myPwd;Persist Security Info=True;User ID=myId;Initial Catalog=MyTable;Data Source=MyCompName\MyDBINSTANCE" myconnection.Open(connectionString, myconnection); %> If someone could please guide me in the right direction I would greatly apprieciate it. Thanking You. Hello, I am very new to HTML. Yesterday I have started learning HTML. I want to make two Dropdown but should be linked with each other. There value should change after click "go" button. In other word I want to make one html for Post Code/Pin Codes of my state. Please Help Me!!! I have made script till he <html> <body> <table width="500" border="0"> <tr> <td colspan="2" style="background-color:#FFA500;"> <h1>PIN CODES OF GOA</h1> </td> </tr> <tr valign="top"> <td style="background-color:#FFD700;width:100px;text-align:top;"> <b>GOA</b><br /> BEACHES<br /> CHURCHES<br /> BARS </td> <td style="background-color:#eeeeee;height:200px;width:400px;text-align:top;"> </body> </html> </body> <form> <select name="menu" style="width:200px;"="font-family:'Arial';color:#FFFFFF;background-color:#000000;font-size:10pt;"> <option value=VASCO</option> <option value=FATORDA</option> </select> <select name="menu" style="width:200px;"="font-family:'Arial';color:#FFFFFF;background-color:#000000;font-size:10pt;"> <option value="403802"</option> <option value="403602"</option> </select> <input type="button" onClick="location=this.form.menu.options[this.form.menu.selectedIndex].value;" value="GO" style="font-family:'Arial';color:#FFFFFF;background-color:#000000;font-size:10pt;"> </form> <script type="text/javascript"> tday =new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"); tmonth=new Array("January","February","March","April","May","June","July","August","September","October","Novem ber","December"); function GetClock(){ d = new Date(); nday = d.getDay(); nmonth = d.getMonth(); ndate = d.getDate(); nyear = d.getYear(); nhour = d.getHours(); nmin = d.getMinutes(); nsec = d.getSeconds(); if(nyear<1000) nyear=nyear+1900; if(nhour == 0) {ap = " AM";nhour = 12;} else if(nhour <= 11) {ap = " AM";} else if(nhour == 12) {ap = " PM";} else if(nhour >= 13) {ap = " PM";nhour -= 12;} if(nmin <= 9) {nmin = "0" +nmin;} if(nsec <= 9) {nsec = "0" +nsec;} document.getElementById('clockbox').innerHTML=""+tday[nday]+", "+tmonth[nmonth]+" "+ndate+", "+nyear+" "+nhour+":"+nmin+":"+nsec+ap+""; setTimeout("GetClock()", 1000); } window.onload=GetClock; </script> <div id="clockbox"></div> </td> </tr> <tr> <td colspan="2" style="background-color:#FFA500;text-align:center;"> Search Your Post Code</td> </tr> </table> I was wondering if there's a quick and simple way to notify a user if an ajax connection is broken, for example you're calling a file, but due to your internet connection, the file cannot be relayed back to you, so the existed javascript code on the initial page you're on, notifys you of the problem. Any ideas? I wrote a script that registers scrolling action as a number, and is stored in the variable delta. Now, I only want to use that variable when scrolling over the div section1 on the page. What would that look like ... this? Code: function something() { if(section1.delta < 0) do something here; } Hi, I'm a newbie to javascript programming and I'm seeking on a solution on how to connect to a tcp port using javascript. Basically, we have phone server that is constantly streaming XML data on port 1024 (serverIP:1024). I've ran a packet sniffer and was able to gather the elements and attributes for the XML data that the server is streaming. Now, I have a test XML parser which works with the XML document using the elements and attributes i've gathered from the packet sniffer. Is there a way for me to connect to the TCP port i've mentioned using javascript and incorporate it with the XML parser that I have. Here is the code for my XML Parser. Quote: <html> <body> <script type="text/javascript"> var xmlDoc; if (window.XMLHttpRequest) { xmlDoc=new window.XMLHttpRequest(); xmlDoc.open("GET","acddataentry.xml",false); xmlDoc.send(""); xmlDoc=xmlDoc.responseXML; } // IE 5 and IE 6 else if (ActiveXObject("Microsoft.XMLDOM")) { xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); xmlDoc.async=false; xmlDoc.load("acddataentry.xml"); } document.write("<table border='1'>"); var x=xmlDoc.getElementsByTagName("ACD"); for (i=0;i<x.length;i++) { document.write("<tr><td>"); document.write(x[i].getElementsByTagName("Calls_Waiting")[0].childNodes[0].nodeValue); document.write("</td><td>"); document.write(x[i].getElementsByTagName("Crt_Wait_Time")[0].childNodes[0].nodeValue); document.write("</td></tr>"); } document.write("</table>"); </script> </body> </html> Any help on this is highly appreciated. Thank in advance. Hello there everyone, I've been stuck on this for about a day and a half. My code is for a connect four game in Javascript. The problem resides in the minimax recursion AI function. Code: function bestMove(color,depth,maxDepth) {//Finsd the best move for the side. Returns column and score pair //depth specifies current level of depth (should be passed as 0) //maxDepth specifies the maximum depth to search //holds the best score var best = new Worth(-100000,0); if(depth%2==1)best.Score*=-1; var mv = new Worth(0,0); for (i=0;i<7;i++) { //try putting a piece at each of 7 columns. mv.Column=i; if(height[i]==-1){ }else{ //find the row to put this piece. gameB[height[i]][i]=color; height[i]--; alert(""+i+""); //find if it is a game over, don't search further if it is //a score of 100 or -100 means a game over var cur = new Worth(0,0); cur.Score=checkWin(height[i],i,color); if(cur.Score==gold){ cur.Score=-100; } if(cur.Score==silver){ cur.Score=100; } if(cur.Score==100||cur.Score==-100||depth==maxDepth){ mv.Score=cur.Score; }else{ //search further (this one is the recursive call if(color==gold) { color = silver; }else{ color = gold; } mv.Score=bestMove(color,depth+1,maxDepth).Score; } //if this move is better, use it instead if(mv.Score>best.Score&&depth%2==0) best=mv; else if(mv.Score<best.Score&&depth%2==1) best=mv; //undo the move. Remove the piece you just put if(getIt(height[i],i)==outside) { alert("OH JEEZ"); } } } return best; } I cannot figure out what is wrong exactly. There maybe a serious error of logic within the function. I posted the .html file on my website www.softdrawing.com/connect4.html with the whole code. If someone could help me fix that function please that would be amazing. I'm new to the minimax algorithm and I tried writing it for myself. What I am trying to do is make a little box that when you hover over it, it will move to a random position. What I am having trouble with is the JavaScript. I have made the code for everything, EXCEPT to move it to a random position. Here is my code so far: Code: <style type='text/css'> #circle1 { background:#007fff; height:20px; margin:0px; position:absolute; width:20px; left:5px; top:5px; -webkit-transition:left 2s linear, top 2s linear; } #circle1:hover { left:25px; top:25px; -webkit-transition:left 0s linear, top 0s linear; } </style> <div id='circle1'></div> I would like the left: and top: in the #circle1:hover to be a random number, to make it go to a random position. I have no clue how to do that though... I have this script added to a facebook icon (#id) on my front page: (function() { var e = document.createElement('script'); e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js'; e.async = true; document.getElementById('fb-root').appendChild(e); })(); window.fbAsyncInit = function() { var fbClicked = false; FB.init({appId: 'Myappid', status: true, cookie: true, xfbml: true}); FB.Event.subscribe('auth.login', function(response) { if(response.session && fbClicked){ window.location = 'http://www.mysite.com/facebookauth/?ref=/'; } }); } function thFBShortCut() { FB.login(function(response) { fbClicked = true; if (response.session && response.perms && fbClicked) { window.location = 'http://www.mysite.com/facebookauth/?ref=/'; } }, {perms:'email,publish_stream'}); } function thFBLogin() { fbClicked = true; $('.popbox').fadeOut(); FB.getLoginStatus(function(response) { if(response.session && response.status == 'connected' && fbClicked) { window.location = 'http://www.mysite.com/facebookauth/?ref=/'; } }); } I want when whenever user press on facebook icon, the script should trigger facebook connect app. I added `<div id="fb-root"></div>` right after `<body <?php body_class(); ?>>`, but when I load my site I keep getting these error messages: document.getElementById("fb-root") is null and FB is not defined [Break On This Error] FB.login(function(response) { My html: <a id="facebookicon" onclick="thFBShortCut()">Login</a> I have a problem with this code. i want to save the result drawing to the database using php as binary format. but i dont know how, can you help me with this. below is my code Code: <div style="width:225px; padding-top:60px; height:452px; margin:0px auto; text-align:center; background:url(template/premium/img/guild.gif) no-repeat top center;"> <form action="" method="post" onsubmit="request('crgild','sh_','POST','index.php'); return false;" id="crgild"> Select Character: <select name="character"> <option value="[ASSASSIN]">[ASSASSIN]</option></select><br><br>NAME: <input class="txt-input" type="text" maxlength="10" name="guildname"><br> <div style="margin:10px;"><div class="guild-top-left2" style="background-color:#000000;"></div> <div class="guild-top-right2" style="background-color:#000000;"></div><div class="guild-top-center2" style="background-color:#000000;"></div> <div class="guild-center-left" style="background-color:#000000;"><div class="guild-center-right"> <table style="width: 150px; height:150px" align=center cellpadding=0 cellspacing=1><tr> <td onclick="addcolor(1);" id="gimage1" style="border:1px solid #555555; cursor:pointer; background:url(template/premium/img/guild-back.gif);" width="15" height="15"> <input type="hidden" name="poscolor[1]" id="poscolor[1]" value="0"></td> <td onclick="addcolor(2);" id="gimage2" style="border:1px solid #555555; cursor:pointer; background:url(template/premium/img/guild-back.gif);" width="15" height="15"> <input type="hidden" name="poscolor[2]" id="poscolor[2]" value="0"></td> <td onclick="addcolor(3);" id="gimage3" style="border:1px solid #555555; cursor:pointer; background:url(template/premium/img/guild-back.gif);" width="15" height="15"> <input type="hidden" name="poscolor[3]" id="poscolor[3]" value="0"></td> <td onclick="addcolor(4);" id="gimage4" style="border:1px solid #555555; cursor:pointer; background:url(template/premium/img/guild-back.gif);" width="15" height="15"> <input type="hidden" name="poscolor[4]" id="poscolor[4]" value="0"></td> <td onclick="addcolor(5);" id="gimage5" style="border:1px solid #555555; cursor:pointer; background:url(template/premium/img/guild-back.gif);" width="15" height="15"> <input type="hidden" name="poscolor[5]" id="poscolor[5]" value="0"></td> <td onclick="addcolor(6);" id="gimage6" style="border:1px solid #555555; cursor:pointer; background:url(template/premium/img/guild-back.gif);" width="15" height="15"> <input type="hidden" name="poscolor[6]" id="poscolor[6]" value="0"></td> <td onclick="addcolor(7);" id="gimage7" style="border:1px solid #555555; cursor:pointer; background:url(template/premium/img/guild-back.gif);" width="15" height="15"> <input type="hidden" name="poscolor[7]" id="poscolor[7]" value="0"></td> <td onclick="addcolor(8);" id="gimage8" style="border:1px solid #555555; cursor:pointer; background:url(template/premium/img/guild-back.gif);" width="15" height="15"> <input type="hidden" name="poscolor[8]" id="poscolor[8]" value="0"></td></tr> <tr><td onclick="addcolor(9);" id="gimage9" style="border:1px solid #555555; cursor:pointer; background:url(template/premium/img/guild-back.gif);" width="15" height="15"> <input type="hidden" name="poscolor[9]" id="poscolor[9]" value="0"></td> <td onclick="addcolor(10);" id="gimage10" style="border:1px solid #555555; cursor:pointer; background:url(template/premium/img/guild-back.gif);" width="15" height="15"> <input type="hidden" name="poscolor[10]" id="poscolor[10]" value="0"></td> <td onclick="addcolor(11);" id="gimage11" style="border:1px solid #555555; cursor:pointer; background:url(template/premium/img/guild-back.gif);" width="15" height="15"> <input type="hidden" name="poscolor[11]" id="poscolor[11]" value="0"></td> <td onclick="addcolor(12);" id="gimage12" style="border:1px solid #555555; cursor:pointer; background:url(template/premium/img/guild-back.gif);" width="15" height="15"> <input type="hidden" name="poscolor[12]" id="poscolor[12]" value="0"></td> <td onclick="addcolor(13);" id="gimage13" style="border:1px solid #555555; cursor:pointer; background:url(template/premium/img/guild-back.gif);" width="15" height="15"> <input type="hidden" name="poscolor[13]" id="poscolor[13]" value="0"></td> <td onclick="addcolor(14);" id="gimage14" style="border:1px solid #555555; cursor:pointer; background:url(template/premium/img/guild-back.gif);" width="15" height="15"> <input type="hidden" name="poscolor[14]" id="poscolor[14]" value="0"></td> <td onclick="addcolor(15);" id="gimage15" style="border:1px solid #555555; cursor:pointer; background:url(template/premium/img/guild-back.gif);" width="15" height="15"> <input type="hidden" name="poscolor[15]" id="poscolor[15]" value="0"></td> <td onclick="addcolor(16);" id="gimage16" style="border:1px solid #555555; cursor:pointer; background:url(template/premium/img/guild-back.gif);" width="15" height="15"> <input type="hidden" name="poscolor[16]" id="poscolor[16]" value="0"></td></tr> <tr><td onclick="addcolor(17);" id="gimage17" style="border:1px solid #555555; cursor:pointer; background:url(template/premium/img/guild-back.gif);" width="15" height="15"> <input type="hidden" name="poscolor[17]" id="poscolor[17]" value="0"></td> <td onclick="addcolor(18);" id="gimage18" style="border:1px solid #555555; cursor:pointer; background:url(template/premium/img/guild-back.gif);" width="15" height="15"> <input type="hidden" name="poscolor[18]" id="poscolor[18]" value="0"></td> <td onclick="addcolor(19);" id="gimage19" style="border:1px solid #555555; cursor:pointer; background:url(template/premium/img/guild-back.gif);" width="15" height="15"> <input type="hidden" name="poscolor[19]" id="poscolor[19]" value="0"></td> <td onclick="addcolor(20);" id="gimage20" style="border:1px solid #555555; cursor:pointer; background:url(template/premium/img/guild-back.gif);" width="15" height="15"> <input type="hidden" name="poscolor[20]" id="poscolor[20]" value="0"></td> <td onclick="addcolor(21);" id="gimage21" style="border:1px solid #555555; cursor:pointer; background:url(template/premium/img/guild-back.gif);" width="15" height="15"> <input type="hidden" name="poscolor[21]" id="poscolor[21]" value="0"></td> <td onclick="addcolor(22);" id="gimage22" style="border:1px solid #555555; cursor:pointer; background:url(template/premium/img/guild-back.gif);" width="15" height="15"> <input type="hidden" name="poscolor[22]" id="poscolor[22]" value="0"></td> <td onclick="addcolor(23);" id="gimage23" style="border:1px solid #555555; cursor:pointer; background:url(template/premium/img/guild-back.gif);" width="15" height="15"> <input type="hidden" name="poscolor[23]" id="poscolor[23]" value="0"></td> <td onclick="addcolor(24);" id="gimage24" style="border:1px solid #555555; cursor:pointer; background:url(template/premium/img/guild-back.gif);" width="15" height="15"> <input type="hidden" name="poscolor[24]" id="poscolor[24]" value="0"></td></tr> <tr><td onclick="addcolor(25);" id="gimage25" style="border:1px solid #555555; cursor:pointer; background:url(template/premium/img/guild-back.gif);" width="15" height="15"> <input type="hidden" name="poscolor[25]" id="poscolor[25]" value="0"></td> <td onclick="addcolor(26);" id="gimage26" style="border:1px solid #555555; cursor:pointer; background:url(template/premium/img/guild-back.gif);" width="15" height="15"> <input type="hidden" name="poscolor[26]" id="poscolor[26]" value="0"></td> <td onclick="addcolor(27);" id="gimage27" style="border:1px solid #555555; cursor:pointer; background:url(template/premium/img/guild-back.gif);" width="15" height="15"> <input type="hidden" name="poscolor[27]" id="poscolor[27]" value="0"></td> <td onclick="addcolor(28);" id="gimage28" style="border:1px solid #555555; cursor:pointer; background:url(template/premium/img/guild-back.gif);" width="15" height="15"> <input type="hidden" name="poscolor[28]" id="poscolor[28]" value="0"></td> <td onclick="addcolor(29);" id="gimage29" style="border:1px solid #555555; cursor:pointer; background:url(template/premium/img/guild-back.gif);" width="15" height="15"> <input type="hidden" name="poscolor[29]" id="poscolor[29]" value="0"></td> <td onclick="addcolor(30);" id="gimage30" style="border:1px solid #555555; cursor:pointer; background:url(template/premium/img/guild-back.gif);" width="15" height="15"> <input type="hidden" name="poscolor[30]" id="poscolor[30]" value="0"></td> <td onclick="addcolor(31);" id="gimage31" style="border:1px solid #555555; cursor:pointer; background:url(template/premium/img/guild-back.gif);" width="15" height="15"> <input type="hidden" name="poscolor[31]" id="poscolor[31]" value="0"></td> <td onclick="addcolor(32);" id="gimage32" style="border:1px solid #555555; cursor:pointer; background:url(template/premium/img/guild-back.gif);" width="15" height="15"> <input type="hidden" name="poscolor[32]" id="poscolor[32]" value="0"></td></tr> <tr><td onclick="addcolor(33);" id="gimage33" style="border:1px solid #555555; cursor:pointer; background:url(template/premium/img/guild-back.gif);" width="15" height="15"> <input type="hidden" name="poscolor[33]" id="poscolor[33]" value="0"></td> <td onclick="addcolor(34);" id="gimage34" style="border:1px solid #555555; cursor:pointer; background:url(template/premium/img/guild-back.gif);" width="15" height="15"> <input type="hidden" name="poscolor[34]" id="poscolor[34]" value="0"></td> <td onclick="addcolor(35);" id="gimage35" style="border:1px solid #555555; cursor:pointer; background:url(template/premium/img/guild-back.gif);" width="15" height="15"> <input type="hidden" name="poscolor[35]" id="poscolor[35]" value="0"></td> <td onclick="addcolor(36);" id="gimage36" style="border:1px solid #555555; cursor:pointer; background:url(template/premium/img/guild-back.gif);" width="15" height="15"> <input type="hidden" name="poscolor[36]" id="poscolor[36]" value="0"></td> <td onclick="addcolor(37);" id="gimage37" style="border:1px solid #555555; cursor:pointer; background:url(template/premium/img/guild-back.gif);" width="15" height="15"> <input type="hidden" name="poscolor[37]" id="poscolor[37]" value="0"></td> <td onclick="addcolor(38);" id="gimage38" style="border:1px solid #555555; cursor:pointer; background:url(template/premium/img/guild-back.gif);" width="15" height="15"> <input type="hidden" name="poscolor[38]" id="poscolor[38]" value="0"></td> <td onclick="addcolor(39);" id="gimage39" style="border:1px solid #555555; cursor:pointer; background:url(template/premium/img/guild-back.gif);" width="15" height="15"> <input type="hidden" name="poscolor[39]" id="poscolor[39]" value="0"></td> <td onclick="addcolor(40);" id="gimage40" style="border:1px solid #555555; cursor:pointer; background:url(template/premium/img/guild-back.gif);" width="15" height="15"> <input type="hidden" name="poscolor[40]" id="poscolor[40]" value="0"></td></tr> <tr><td onclick="addcolor(41);" id="gimage41" style="border:1px solid #555555; cursor:pointer; background:url(template/premium/img/guild-back.gif);" width="15" height="15"> <input type="hidden" name="poscolor[41]" id="poscolor[41]" value="0"></td> <td onclick="addcolor(42);" id="gimage42" style="border:1px solid #555555; cursor:pointer; background:url(template/premium/img/guild-back.gif);" width="15" height="15"> <input type="hidden" name="poscolor[42]" id="poscolor[42]" value="0"></td> <td onclick="addcolor(43);" id="gimage43" style="border:1px solid #555555; cursor:pointer; background:url(template/premium/img/guild-back.gif);" width="15" height="15"> <input type="hidden" name="poscolor[43]" id="poscolor[43]" value="0"></td> <td onclick="addcolor(44);" id="gimage44" style="border:1px solid #555555; cursor:pointer; background:url(template/premium/img/guild-back.gif);" width="15" height="15"> <input type="hidden" name="poscolor[44]" id="poscolor[44]" value="0"></td> <td onclick="addcolor(45);" id="gimage45" style="border:1px solid #555555; cursor:pointer; background:url(template/premium/img/guild-back.gif);" width="15" height="15"> <input type="hidden" name="poscolor[45]" id="poscolor[45]" value="0"></td> <td onclick="addcolor(46);" id="gimage46" style="border:1px solid #555555; cursor:pointer; background:url(template/premium/img/guild-back.gif);" width="15" height="15"> <input type="hidden" name="poscolor[46]" id="poscolor[46]" value="0"></td> <td onclick="addcolor(47);" id="gimage47" style="border:1px solid #555555; cursor:pointer; background:url(template/premium/img/guild-back.gif);" width="15" height="15"> <input type="hidden" name="poscolor[47]" id="poscolor[47]" value="0"></td> <td onclick="addcolor(48);" id="gimage48" style="border:1px solid #555555; cursor:pointer; background:url(template/premium/img/guild-back.gif);" width="15" height="15"> <input type="hidden" name="poscolor[48]" id="poscolor[48]" value="0"></td></tr> <tr><td onclick="addcolor(49);" id="gimage49" style="border:1px solid #555555; cursor:pointer; background:url(template/premium/img/guild-back.gif);" width="15" height="15"> <input type="hidden" name="poscolor[49]" id="poscolor[49]" value="0"></td> <td onclick="addcolor(50);" id="gimage50" style="border:1px solid #555555; cursor:pointer; background:url(template/premium/img/guild-back.gif);" width="15" height="15"> <input type="hidden" name="poscolor[50]" id="poscolor[50]" value="0"></td> <td onclick="addcolor(51);" id="gimage51" style="border:1px solid #555555; cursor:pointer; background:url(template/premium/img/guild-back.gif);" width="15" height="15"> <input type="hidden" name="poscolor[51]" id="poscolor[51]" value="0"></td> <td onclick="addcolor(52);" id="gimage52" style="border:1px solid #555555; cursor:pointer; background:url(template/premium/img/guild-back.gif);" width="15" height="15"> <input type="hidden" name="poscolor[52]" id="poscolor[52]" value="0"></td> <td onclick="addcolor(53);" id="gimage53" style="border:1px solid #555555; cursor:pointer; background:url(template/premium/img/guild-back.gif);" width="15" height="15"> <input type="hidden" name="poscolor[53]" id="poscolor[53]" value="0"></td> <td onclick="addcolor(54);" id="gimage54" style="border:1px solid #555555; cursor:pointer; background:url(template/premium/img/guild-back.gif);" width="15" height="15"> <input type="hidden" name="poscolor[54]" id="poscolor[54]" value="0"></td> <td onclick="addcolor(55);" id="gimage55" style="border:1px solid #555555; cursor:pointer; background:url(template/premium/img/guild-back.gif);" width="15" height="15"> <input type="hidden" name="poscolor[55]" id="poscolor[55]" value="0"></td> <td onclick="addcolor(56);" id="gimage56" style="border:1px solid #555555; cursor:pointer; background:url(template/premium/img/guild-back.gif);" width="15" height="15"> <input type="hidden" name="poscolor[56]" id="poscolor[56]" value="0"></td></tr> <tr><td onclick="addcolor(57);" id="gimage57" style="border:1px solid #555555; cursor:pointer; background:url(template/premium/img/guild-back.gif);" width="15" height="15"> <input type="hidden" name="poscolor[57]" id="poscolor[57]" value="0"></td> <td onclick="addcolor(58);" id="gimage58" style="border:1px solid #555555; cursor:pointer; background:url(template/premium/img/guild-back.gif);" width="15" height="15"> <input type="hidden" name="poscolor[58]" id="poscolor[58]" value="0"></td> <td onclick="addcolor(59);" id="gimage59" style="border:1px solid #555555; cursor:pointer; background:url(template/premium/img/guild-back.gif);" width="15" height="15"> <input type="hidden" name="poscolor[59]" id="poscolor[59]" value="0"></td> </tr> <tr></table></div></div> <div class="guild-bottom-left" style="background-color:#000000;"></div><div class="guild-bottom-right" style="background-color:#000000;"></div> <div class="guild-bottom-center" style="background-color:#000000;"></div></div> <div id="currentcolor2" style="width:15px; float:left; margin-left:30px; height:15px; border:1px solid #555555; background:url(template/premium/img/guild-back.gif);"></div> <div style="float:feft; text-align:left; margin-left:50px; margin-right:20px;">After selecting a color with the mouse, please draw.</div><br> <table align=center cellpadding=0 cellspacing=0 border=1><tr> <td onclick="changecolor(this.style.background,0)" style="cursor:pointer; background:url(template/premium/img/guild-back.gif);" width="15" height="15"></td> <td onclick="changecolor(this.style.background,1)" style="cursor:pointer; background:#000000;" width="15" height="15"></td> <td onclick="changecolor(this.style.background,2)" style="cursor:pointer; background:#8c8a8d;" width="15" height="15"></td> <td onclick="changecolor(this.style.background,3)" style="cursor:pointer; background:#ffffff;" width="15" height="15"></td> <td onclick="changecolor(this.style.background,4)" style="cursor:pointer; background:#fe0000;" width="15" height="15"></td> <td onclick="changecolor(this.style.background,5)" style="cursor:pointer; background:#ff8a00;" width="15" height="15"></td> <td onclick="changecolor(this.style.background,6)" style="cursor:pointer; background:#ffff00;" width="15" height="15"></td> <td onclick="changecolor(this.style.background,7)" style="cursor:pointer; background:#8cff01;" width="15" height="15"></td></tr> <tr><td onclick="changecolor(this.style.background,8)" style="cursor:pointer; background:#00ff00;" width="15" height="15"></td> <td onclick="changecolor(this.style.background,9)" style="cursor:pointer; background:#01ff8d;" width="15" height="15"></td> <td onclick="changecolor(this.style.background,'A')" style="cursor:pointer; background:#00ffff;" width="15" height="15"></td> <td onclick="changecolor(this.style.background,'B')" style="cursor:pointer; background:#008aff;" width="15" height="15"></td> <td onclick="changecolor(this.style.background,'C')" style="cursor:pointer; background:#0000fe;" width="15" height="15"></td> <td onclick="changecolor(this.style.background,'D')" style="cursor:pointer; background:#8c00ff;" width="15" height="15"></td> <td onclick="changecolor(this.style.background,'E')" style="cursor:pointer; background:#ff00fe;" width="15" height="15"></td> <td onclick="changecolor(this.style.background,'F')" style="cursor:pointer; background:#ff008c;" width="15" height="15"></td> </tr></table> <input type="hidden" id="currentcolor" value=""><br><br> <input class="guild-submit" name="createguild" type="submit" value="Create"></form></div> <script type="text/javascript"> function changecolor(color,encode) { document.getElementById('currentcolor').value=encode; document.getElementById('currentcolor2').style.background=color; } function addcolor(id) { document.getElementById('poscolor['+id+']').value=document.getElementById('currentcolor').value; document.getElementById('gimage'+id).style.background=document.getElementById('currentcolor2').style.background; } </script> <input type="hidden" id="new_credits" value="0"> seems easy yet frustrating trying to learn how. i set up a column in the MySql database that holds an integer, lets call it IMG_INDEX; easy enough. in my prgm.php, i need to use the values stored in IMG_INDEX (in the database) to contol which image is currently displayed in the browser. i need to be able to update to value of IMG_INDEX in the database from the code. i need to be able to retrieve the value of IMG_INDEX from the database with the code. note: this is NOT a user input thing, or a display of database info thing. i'm using IMG_INDEX as a switch to control which image is displayed at different times during a web browing session. ?? so here is the question ?? how do i send a new integer (like 2) to the database and store it in IMG_INDEX ? how do i retrieve the value of IMG_INDEX from the database ? i need to do this all from the javascript area in the head of the php code, and occasionally from the body area of the php code. if you have a tip, i'd really appreciate your help. thank you, Paul Williams todays weather in Kalispell, MT COLD i say again COLD, COLD, COLD. brrrrrrrrrrrr <script type="text/javascript"> function disp_confirm(){ var name=confirm("Are you sure that you want to do this?") if (name==true){ perform database delete here }else{ document.write("Cancel!") } } I'm not sure whether this can be done, but can I perform a database delete where indicated? Can you suggest a code snippet so I can see the style? Thanks for your help. Hello according to this http://www.w3schools.com/php/php_ajax_database.asp I prepared mine search which works fine. it displays which products are intel and which amd for example. I wonder how can i add a second similar search for sochet or something else,but not separate one for example if i have selected the intel as 1st option then choosing my 2nd one it display only intel products. Here is my current code: Code: <script type="text/javascript"> function showUser(str) { if (str=="") { document.getElementById("txtHint").innerHTML=""; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("txtHint").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","kailoipa.php?q="+str,true); xmlhttp.send(); } </script> </head> <body> <form> <select name="products" onchange="showUser(this.value)"> <option value="">Select a person:</option> <option value="intel">intel</option> <option value="amd">amd</option> </select> </form> <br /> <div id="txtHint"><b>Person info will be listed here.</b></div> </body> </html> Hi Guys... First of all thanks upfront for the help... I have this code: Code: /* Takes value from div */ var RealyDude = document.getElementById('ThisIsTheType'); var OmgWTF2 = RealyDude.innerHTML; /* Asigns value to hidden field */ document.getElementById('boldstuff2').value = OmgWTF2; And the div looks like this Code: <div class="item-inttype" ID="ThisIsTheType">RCCB Enterpise</div> And the hidden field looks like this Code: <input type="text" id="boldstuff3" name="GettingTheType" width="200" value=""/> The problem that I am having On submit of the form I pass the code to a php script... This works well in all browsers... I have used the php echo function to make sure that the data is infact being passed to the php script, in all cases it definately is. Then I query a database using the data from that hidden field But for some reason , the script only works in IE...Which leads me to believe that when the data is passed from Firefox or chrome: That it is somehow adding hidden characters to the string... As even though I am using different browsers php always gets the variable Any help ok this is all hyperthetical and ground work (phishing) for me so any and advice will be warmly welcomed. I would like to start and e-commerce site BUT: I'm sure i should use javascript on client side to validate an order form BUT 1) server side, how is the order revalidated --- ie is javascript used again on server or use of another language? 2) could someone explain how information from order form is connected to an (SQL) database ---- and how is that database then updated? What language is used? (I am talking about the general process here) At the momment i'm researching SQL http://dev.mysql.com/doc/refman/5.5/...ving-data.html and e-commerce database design http://www.princeton.edu/~rcurtis/ul...mdatabase.html but I have no idea how all this is connected and where Javascript finishes and where I need to research further in oreder to put things together. Any help would be fantastic sorry for the novice questions. low tech Okay, I'm good at PHP but using javascript so the user doesnt need to refresh the page is a neat thing. I want to make a button that says "Do you like this game? Yes or No" How can I use javascript to tell Yes to send games->rating_yes = 1 or No games->rating_no = 1 Or if you could link me with resource on building something that can teach me how to use javascript to update/insert into my database. I've tried stuff like this Code: Do you like this game? <a href="javascript://" onclick="ajaxYESorNO('<?=$gameid;?>','like');">Yes</a> or <a href="javascript://" onclick="ajaxYESorNO('<?=$gameid;?>','dislike');">No</a> Code: function ajaxYESorNO(gameid,answer) { ajax = ajaxFunction(); ajax.onreadystatechange = function () { ajaxRateGame_stateChanged(vote); }; var url = base_url+ "includes/ajaxYESorNO.php"; url = url+ "?vote=" +answer; url = url+ "&gameid=" +gameid; ajax.open("GET",url,true); ajax.send(null); } PHP Code: <?php $gameid = $_GET[gameid]; $vote = $_GET[vote]; @include "config.php"; if($_GET['vote']=='like') { $result = $GLOBALS['dFetch']->exec ("update games set rate_yes=rate_yes+1 where gameid = $gameid"); } else { $result = $GLOBALS['dFetch']->exec ("update games set rate_no=rate_no+1 where gameid = $gameid"); } ?> But yet cant seem to figure how to get it working properly Thanks. I need help making this timed quiz so when you hit submit it goes into a mysql database. right now it just tells you if you answered correctly or not Here is the code: what color is the grass? <input type = "text" id = "answer"> <input type = "button" id = "time" onclick="answer()"> <script type = "text/javascript"> var n = 60; // modify this for number of seconds to answer document.getElementById( 'time').value = "Answer in " + n + " seconds"; var i = setInterval('count()' , 1000); var tooLate; function count() { tooLate = 0; n--; if(n >=0) { document.getElementById( 'time').value = "Answer in " + n + " seconds"; } else { clearInterval(i); alert("Too late!"); document.getElementById('answer').value = ""; tooLate = 1; } } function answer() { var correct = "green"; // This is the correct answer if (tooLate == 0) { if(document.getElementById( 'answer').value == correct) { clearInterval(i); alert("Right Answer with " + n + " seconds remaining"); } else{ clearInterval(i); alert("Incorrect! The answer was " + correct); } } } </script> IS THIS THE CORRECT CODE ??????????? <?php $host="localhost"; // Host name $username=""; // Mysql username $password=""; // Mysql password $db_name="test"; // Database name $tbl_name="test_mysql"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $sql="SELECT * FROM $tbl_name"; $result=mysql_query($sql); $count=mysql_num_rows($result); ?> <table width="400" border="0" cellspacing="1" cellpadding="0"> <tr> <td><form name="form1" method="post" action=""> <table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td bgcolor="#FFFFFF"> </td> <td colspan="4" bgcolor="#FFFFFF"><strong>Delete multiple rows in mysql</strong> </td> </tr> <tr> <td align="center" bgcolor="#FFFFFF">#</td> <td align="center" bgcolor="#FFFFFF"><strong>Id</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Name</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Lastname</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Email</strong></td> </tr> <?php while($rows=mysql_fetch_array($result)){ ?> <tr> <td align="center" bgcolor="#FFFFFF"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $rows['id']; ?>"></td> <td bgcolor="#FFFFFF"><? echo $rows['id']; ?></td> <td bgcolor="#FFFFFF"><? echo $rows['name']; ?></td> <td bgcolor="#FFFFFF"><? echo $rows['lastname']; ?></td> <td bgcolor="#FFFFFF"><? echo $rows['email']; ?></td> </tr> <?php } ?> <tr> <td colspan="5" align="center" bgcolor="#FFFFFF"><input name="delete" type="submit" id="delete" value="Delete"></td> </tr> <? // Check if delete button active, start this if($delete){ for($i=0;$i<$count;$i++){ $del_id = $checkbox[$i]; $sql = "DELETE FROM $tbl_name WHERE id='$del_id'"; $result = mysql_query($sql); } // if successful redirect to delete_multiple.php if($result){ echo "<meta http-equiv=\"refresh\" content=\"0;URL=delete_multiple.php\">"; } } mysql_close(); ?> </table> </form> </td> </tr> </table> I have a problem with programming in JS the following; first part of the problem: In the middle of the site would be a short text (some kind of quote) which you could refresh simply by clicking on a button bellow text (in this case a new quote would appear in the text box) or you could agree with the quote by clicking on second button bellow the code (in this case there would appear a smiley face in the text box). Quotes would be randomly selected from the database. second part of the problem: I also wish to record whether or not people agree with the quote. I was suggested to use server side language like PHP or ASP to write the results to a file or database on the server. Honestly I have absolutely no idea how to do this. I am familiar with basic HTML but JS is a whole new planet for me. I have spend days trying to figure out the solution but still don't know what to do which is why any sort of help would be greatly appreciated. Thanks in advance |