Jump to content

DaVuLf

Members
  • Posts

    124
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

DaVuLf's Achievements

Member

Member (2/5)

0

Reputation

  1. After doing some digging, it seems like ASP requires a server to be running on the host computer. Considering this is supposed to be run without a server (only a database), I don't think the ASP will work (although correct me if I'm wrong). As a result, is there any way to code the ASP there into JavaScript? Thanks, DaVuLF
  2. Okay, so I have tried another approach found at: http://www.w3schools.com/ajax/ajax_database.asp Here is the HTML: (dictionary.html) <html> <head> <script src="selectterm.js"></script> </head> <body> <form> Select a term: <select name="terms" onchange="showTerm(this.value)"> <option value="Client">Client <option value="NORTS ">North/South <option value="WOLZA">Wolski Zajazd </select> </form> <p> <div id="txtHint"><b>term info will be listed here.</b></div> </p> </body> </html> Here is the JS: (selectterm.js) var xmlHttp function showTerm(str) { xmlHttp=GetXmlHttpObject(); if (xmlHttp==null) { alert ("Your browser does not support AJAX!"); return; } var url="getterm.asp"; url=url+"?q="+str; url=url+"&sid="+Math.random(); xmlHttp.onreadystatechange=stateChanged; xmlHttp.open("GET",url,true); xmlHttp.send(null); } function stateChanged() { if (xmlHttp.readyState==4) { document.getElementById("txtHint").innerHTML=xmlHttp.responseText; } } function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; } Here is the ASP: (getterm.asp) <% response.expires=-1 sql="SELECT * FROM tablename WHERE term_name=" sql=sql & "'" & request.querystring("q") & "'" set cn = new ActiveXObject("ADODB.Connection"); set strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = c:\\PCL\\test.mdb;Persist Security Info=False"; cn.Open(strConn); set rs = Server.CreateObject("ADODB.recordset") rs.Open sql, conn response.write("<table>") do until rs.EOF for each x in rs.Fields response.write("<tr><td><b>" & x.term_name & "</b></td>") response.write("<td>" & x.term_text & "</td></tr>") next rs.MoveNext loop response.write("</table>") %> I changed the values in the tutorial for my values, but it isn't working either in Opera, or IE7. In Opera it outputs the ASP code without any variables filled in, in IE7 it does nothing. I didn't really change anything aside from what I was looking for, and yet it isn't working. Thanks for any help!
  3. Hi DJ Kat, That didn't quite seem to work out. I will post the entire code that I am currently using, as that may help a little more. Essentially what I am trying to do is to have a select dropdown populated by values in a database, and then upon selecting one of those, to have the associated text (ie, the column in the database beside the name) to appear in a textarea below the dropdown. Here is the code: <html> <head> <title>Untitled Document</title> <script language="JavaScript"> function getQueryVariable(variable) { var query = window.location.search.substring(1); var vars = query.split("&"); for (var i=0;i<vars.length;i++) { var pair = vars[i].split("="); if (pair[0] == variable) { return pair[1]; } } } function changeText(){ var userInput = document.getElementById('testinput').value; document.getElementById('boldStuff2').innerHTML = userInput; var cn = new ActiveXObject("ADODB.Connection"); var strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = c:\\PCL\\test.mdb;Persist Security Info=False"; cn.Open(strConn); var rs = new ActiveXObject("ADODB.Recordset"); var SQL = "select * from tablename WHERE term_name='"+userInput+"'"; rs.Open(SQL, cn); var definition = rs(2).value; document.write(definition); //document.write("document.getElementByID('boldStuff3').innerHTML ="definition) document.getElementsById('boldStuff3').innerHTML = definition; document.getElementsById('userText').value = definition; document.write(name); rs.Close(); cn.Close(); } //Initiate the connection to the database. var cn = new ActiveXObject("ADODB.Connection"); var strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = c:\\PCL\\test.mdb;Persist Security Info=False"; cn.Open(strConn); var rs = new ActiveXObject("ADODB.Recordset"); var SQL = "select * from tablename"; rs.Open(SQL, cn); document.write("<form name='testform' action='test3.html' method='get'>"); document.write("<select id='testinput' name='testinput'>"); while(!rs.eof) { document.write("<option value='"+rs(1)+"'>"+rs(1)+"</option>"); document.write(rs(1) + "<br>"); rs.MoveNext() } document.write("</select>"); document.write("<input type='submit' value='Show'>"); document.write("</form>"); rs.Close(); cn.Close(); var name = getQueryVariable("testinput"); name.replace(/\+/g," "); document.getElementsById('boldStuff3').innerHTML = name; </script> </head> <body> <p>Welcome to the site <b id='boldStuff2'>dude</b> </p> <p>Welcome to the site <b id='boldStuff3'>dude</b> </p> <p><textarea id='userText'></textarea></p> <input type='button' onclick='changeText()' value='Change Text'/> </body> </html> Thanks for the help, I appreciate it!
  4. Hi there, I am having trouble with a couple of things on my file. First off, I have passed a variable through the URL, and it is not getting parsed properly. For instance: var name = getValue("testinput"); name.replace(/\+/g," "); That should eliminate the +'s between words. It does not. Second, I am trying to pull a value from a recordset: var cn = new ActiveXObject("ADODB.Connection"); var strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = c:\\PCL\\test.mdb;Persist Security Info=False"; cn.Open(strConn); var rs = new ActiveXObject("ADODB.Recordset"); var SQL = "select * from tablename WHERE term_name='"+userInput+"'"; rs.Open(SQL, cn); var definition = rs(2).value; //document.write("document.getElementByID('boldStuff3').innerHTML ="definition) document.getElementsById('boldStuff3').innerHTML = definition; document.getElementsById('userText').value = definition; Unfortunately, The innerHTML is not working. If I do a document.write(definition), it outputs the proper information, but changing it inline is not working at all. Please let me know. Thanks, DaVuLF
  5. Hey there. I'm having an issue with the following set of commands: //Check to see if we already have an entry for the acquiror stock $acquiror_existence_query = "SELECT * FROM portfolio WHERE team='$team_name' AND stock='$acquiror' AND flag='0'"; echo $acquiror_existence_query.'<br />'; $acquiror_existence = mysql_query($acquiror_existence_query) or die(mysql_error()); echo $acquiror_existence.'<br />'; if($acquiror_existence){ //Check to see the value of these shares $acquiror_value = mysql_result($acquiror_existence,0,"value"); //Check the quantity that they have $acquiror_quantity = mysql_result($acquiror_existence,0,"quantity"); } else { //If it doesn't exist, set it to 0. $acquiror_value = 0; $acquiror_quantity = 0; } Most specifically, this is happening because I am running a check to see if $acquiror_existence is true (ie, it exists) then running the appropriate segment of the if statement. Here is the results of my echoes. SELECT * FROM portfolio WHERE team='bcom4' AND stock='MRK' AND flag='0' Resource id #15 Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 15 in C:\Program Files\xampp\htdocs\wdt\events.php on line 109 Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 15 in C:\Program Files\xampp\htdocs\wdt\events.php on line 111 For some reason this is giving me some errors. I don't quite understand, but if someone could clarify, or help out, that would be fantastic. As it is, the string that it is looking for is not actually in the 'portfolio' table. There is no line with that description, as a result it should return the error, and then it should follow into the 'else' segment of the if statement, as acquiror_existence would be switched to 'false'. Thanks for any help, DaVuLF
  6. Well... I figured out how to do it by improvising. Using several while loops, about a dozen queries, and the SELECT SUM features. Thanks, DaVuLf
  7. I think this would be like in access where you link two fields of the table, and pull down the third... Is this not possible in mySQL (ie, to set relationships?). Thanks, DaVuLF
  8. Hey there, I know this is something that is really easy to do in something like Access, so I'm hoping its easy to do with PHP as well. I'm running a SQL backend, but I think that since the code itself is PHP, this is the proper place to post. Now then, I have a table set up as follows: [code] TEAM    FIELD  VALUE [/code] Pretty simple, I know. So the value can either be zero, or non-zero. What I need to do is to separate the non-zero entries, and then update them with values from another table. The problem is that a team could have more than one entry if it has different fields. For example, team 1 has field 2,3 and 4, all with non-zero entries. However, team 1 also has field 1 and 5 with zero in them. This means that I would need to update the fields 2,3 and 4 for team 1 and leave the other two unchanged. Now let's throw in some more complexity. I have a separate table for every field, they are all identical, and are as follows: [code] NUMBER  VALUE [/code] [sup]*The name of the table is field 'x' (where x denotes the number)[/sup] I need to take the values at 'NUMBER' = 60, and put them in the other table to replace the ones I had previously. Essentially I'm matching the values in the first table with those in the second, while adding a few conditions. I hope this was clear, if you have any further questions or need more elaboration, please don't hesitate to ask. Thank you, DaVuLF
  9. Yea. I was hoping that I wouldn't have to go that way. I'm currently using a meta refresh at 10seconds. I suppose this is the best way. Thanks for the replies guys.
  10. Thats essentially what I have written out in PHP, but that is not what is currently at issue. Right now I have access to a variable that I can run a modular on to determine if it is divisible by 60, and if so, then to refresh the page (which would refresh on the minute, every minute). The only question is how to run this loop without locking up my SQL, since the times are both taken from my database. Then the question would be how to refresh the darned HTML once the condition is satisfied. I will keep giving it a shot :). Thanks for the reply though.
  11. Hey there. I have a script that keeps track of minutes, and without being too processor intensive (ie checking every 60 seconds) I want my page to refresh as soon as the minute changes. Is there any way to accomplish this? I know that this is quite vague, although I'm not sure how better to explain myself. Currently I'm using a meta refresh every 10 seconds or so, but this has the opportunity to miss the minute mark. Would there be any way to do so? If you need any of my code or whatnot, please let me know. Thanks, DaVulF
  12. More or less. Now I'm not so much trying to add those fields, as to set one only visible by the admins and not by anyone else. I also wanted to know how to designate someone as a 'dono'r if they have paid or not.
  13. Are there tutorials or anything on this?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.