Jump to content

Search the Community

Showing results for tags 'global'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • HTML/XHTML
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • XSLT/XSL-FO
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

Calendars

  • Community Calendar

Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Languages

Found 9 results

  1. fetch multiple rows outside function

    Hi All, I'm looking for a solution in using a function. The function fetches data from a database. In a column multiple results are found. I want to have all the records outisde the function. Inside the function all records are shown, but outside only the last record. I thought I could use return array, but it only returns multiple variables and not multiple rows. Not sure if fetch() is the solution for arrays. example: <?php function test_func($val4) { global $val1; global $val2; global $val4; $servername = "host"; $username = "johndoe"; $password = "admin"; $dbname = "dbase_db"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } // if ($stmt = $conn->prepare("SELECT col1, col2 FROM table WHERE col4 = ? ; ")) { $stmt->bind_param("s", $val4); $stmt->execute(); $stmt->store_result(); $num_of_rows = $stmt->num_rows; var_dump($num_of_rows); $stmt->bind_result($val1, $val2); if ($num_of_rows > 0){ while ($stmt->fetch()) { // managed to output multiple rows here, but that's not the goal } return array ($val1, $val2); } } } $val4='form_value'; test_func($val4); // return multiple rows here, outside the function How should I solve this?
  2. when working with $_SESSION and creating a super global then in the script where I use include and call the variable the entire form is showing up. I have to work with $_SESSION, because $_POST or $_GET wont work in this situation. Is there a way to transfer a form value to another script, and then a single value and not the complete form with everything in it.
  3. Global HTML variables

    It occurs from time to time that a website url reference that is used site wide changes. For example if the site starts using php then index.htm has to change to index.php. Is there a way of creating site wide html variables for this purpose to save searching for and editing many references on the site.
  4. Hi guys, I just have a dumb question but looks like I can't find the answer anywhere at all. What is a global function? specifically, how do I determine the scope of a function? I know the definition of the variable scope, but function scope, I don't, hope you guys could clarify this for me. One more thing. I have this code down below about the "this" keyword. Doesn't the "this" keyword refer to the element that triggers the event? if so, why it pops up "undefined" when I click on the paragraph? I'm pretty positive "this" in my case is bound to a global variable(that's why it gives me an "undefined" id) which is the window object, but I don't understand why "this" is not referring to the "<p>" element at all. Any tips and hints are greatly appreciated brothers(Please take it easy on me if I sound dumb, I just started teaching myself JS a couple weeks ago or so, so) Thank you very much guys. <!DOCTYPE html><html><head><script>function myFunction(){ alert(this.id);}</script></head><body><p id = "myPa" onclick="myFunction()">This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph.</p></body></html>
  5. The last example for window.clearTimeout() method has an explanation that appears to be inconsistent with the 'try it yourself' example on the JavaScript Timing Events page. I have put the text needing corrected in red: How to Stop the Execution?The clearInterval() method is used to stop further executions of the function specified in the setInterval() method. Syntaxwindow.clearInterval(intervalVariable) The window.clearInterval() method can be written without the window prefix. To be able to use the clearInterval() method, you must use a global variable when creating the interval method: myVar=setInterval("javascript function",milliseconds); Then you will be able to stop the execution by calling the clearInterval() method. ExampleSame example as above, but we have added a "Stop time" button: <p id="demo"></p><button onclick="myStopFunction()">Stop time</button><script>var myVar=setInterval(function(){myTimer()},1000);function myTimer(){var d=new Date();var t=d.toLocaleTimeString();document.getElementById("demo").innerHTML=t;}function myStopFunction(){clearInterval(myVar);}</script> Try it yourself ยป If I have been learning my lessons correctly, typing in var makes the variable local. If this is the case, then it would seem the clearInterval() worked without setting a global variable. Does this need updated?
  6. [SOLVED] Query: JS Variables

    The code below works fine (apart from in Safari but that's a different problem). You can see the working code in action here: http://codepen.io/deldalton/full/mfoIi function expandNav() { var nav = document.getElementById("navBar"); if (nav.className == "collapsed") { nav.className = "expanded"; document.getElementById("navButton").src="images/lightNavUp.png";} else { nav.className = "collapsed"; document.getElementById("navButton").src="images/lightNavDown.png";}}function changeIconOnMouseOver() { if (document.getElementById("navBar").className == "collapsed") { document.getElementById("navButton").src="images/lightNavDown.png";} else { document.getElementById("navButton").src="images/lightNavUp.png";}}function changeIconOnMouseOut() { if (document.getElementById("navBar").className == "collapsed") { document.getElementById("navButton").src="images/darkNavDown.png";} else { document.getElementById("navButton").src="images/darkNavUp.png";}} However, using the following code which is basically the same thing except using global variables instead of "document.getElementById"s all the time, doesn't work. var nav = document.getElementById("navBar");var button = document.getElementById("navButton");function expandNav() { if (nav.className == "collapsed") { nav.className = "expanded"; button.src="images/lightNavUp.png";} else { nav.className = "collapsed"; button.src="images/lightNavDown.png";}}function changeIconOnMouseOver() { if (nav.className == "collapsed") { button.src="images/lightNavDown.png";} else { button.src="images/lightNavUp.png";}}function changeIconOnMouseOut() { if (nav.className == "collapsed") { button.src="images/darkNavDown.png";} else { button.src="images/darkNavUp.png";}} Can anyone tell me why?
  7. JavaScript global variable...

    Although I can console.log lastSel it is coming up as a blank when the PHP is called in the header. So when the header is passed it is id: "" even though clearly there is a value in lastSel and I am type casting to string. I am wondering what could be the source of the issue. lastSel is defined outside of any function braces as just "lastSel = """ without using the var keyword. Why would it be blank as String(lastSel) even though I can console.log a value? <script>$(function(){var date = new Date();var d = date.getDate();var m = date.getMonth();var y = date.getFullYear(); $('#calendar1').fullCalendar({ // put your options and callbacks hereheader:{left: 'prev,next today',center: 'title',right: 'month,basicWeek,basicDay'},editable: true,droppable: true,selectable: true,events: {url: 'php.scripts/events.get.php',type: 'POST',data: {id: String(lastSel),custom_param2: 'somethingelse'},error: function() {alert('there was an error while fetching events!');},color: 'yellow', // a non-ajax optiontextColor: 'black' // a non-ajax option},eventClick: function (calEvent, jsEvent, view) { $( "#eventdialog2" ).dialog({resizable: false,height:500,width:500,modal: true,buttons: {"Update": function() {$( this ).dialog( "close" );},Cancel: function() {$( this ).dialog( "close" );}}}); },eventDrop: function (event, dayDelta, minuteDelta, allDay, revertFunc) { },select: function(startDate, endDate, allDay, jsEvent, view) { $( "#eventdialog1" ).dialog({resizable: false,height:500,width: 500,modal: true,buttons: {"Add": function() {if(jQuery("#event_title1").val() == ""){alert("All active text fields are required input!");return false;}$( this ).dialog( "close" );},Cancel: function() {$( this ).dialog( "close" );}}}); } }); $('#calendar2').fullCalendar({ // put your options and callbacks here });});</script> <script>lastSel = "";$(function(){ $("#list").jqGrid({ url:'php.scripts/get.customers.php', datatype: 'xml', mtype: 'POST',colNames:['idcustomers','firstname', 'lastname','address1','address2','city','state','zip','phone','email','cell'], colModel :[ {name:'idcustomers', index:'idcustomers', width:55}, {name:'firstname', index:'firstname', width:90, editable: true}, {name:'lastname', index:'lastname', width:90, editable: true}, {name:'address1', index:'address1', width:90, editable: true}, {name:'address2', index:'address2', width:90, editable: true}, {name:'city', index:'city', width:90, editable: true}, {name:'state', index:'state', width:90, editable: true}, {name:'zip', index:'zip', width:90, editable: true}, {name:'phone', index:'phone', width:90, editable: true}, {name:'email', index:'email', width:90, editable: true}, {name:'cell', index:'cell', width:90, editable: true} ], pager: '#pager', rowNum:20, rowList:[20,100,300], sortname: 'idcustomers', sortorder: 'asc', viewrecords: true, gridview: true, caption: 'Customers',width: 1400,height: 290,editurl: 'php.scripts/update.row.php',ajaxGridOptions: {type:"POST"},onSelectRow: function(id){ if(id && id!==lastSel){ jQuery('#gridid').restoreRow(lastSel); lastSel=id;jQuery("#list").data('selid',lastSel);console.log(lastSel);console.log(jQuery("#list").data('selid'));} //jQuery('#list').editRow(id, true); jQuery('#list').data('selid', jQuery("#list").getCell(lastSel,0));jQuery('#list').data('firstname', jQuery("#list").getCell(lastSel,1));jQuery('#list').data('lastname', jQuery("#list").getCell(lastSel,2));jQuery('#list').data('address1', jQuery("#list").getCell(lastSel,3));jQuery('#list').data('address2', jQuery("#list").getCell(lastSel,4));jQuery('#list').data('city', jQuery("#list").getCell(lastSel,5));jQuery('#list').data('state', jQuery("#list").getCell(lastSel,6));jQuery('#list').data('zip', jQuery("#list").getCell(lastSel,7));jQuery('#list').data('phone', jQuery("#list").getCell(lastSel,8));jQuery('#list').data('email', jQuery("#list").getCell(lastSel,9));jQuery('#list').data('cell', jQuery("#list").getCell(lastSel,10)); } }).jqGrid('navGrid','#pager',{ edit: false, add: true }, {}, {}, {}, {}, {}).jqGrid('inlineNav',"#pager",{}); }); </script>
  8. Ok, the deal is as follows: I've got a function in a class.Within that function is another function called by uasort(), a custom array sorting function.The main function contains some variables which should be used in the sorting function.However I do not know how they can be accessed, and they can't be included as extra arguments in the function because the uasort only allows 2. Example: function somefunction() { $bar=5; $foo=4; function sorter($arg1,$arg2) { $bar & $foo should be accessed from here... } uasort($someArray,"sorter"); } If there's any way to access $bar & $foo from the sorting function please let me know. Gr.Viller
  9. Going global with variables.

    I am trying to figure out how to go global with these variables. This works great: <!DOCTYPE html><html><head><title>My Title</title><script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script><script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script><script>$(document).ready(function(){ $('#map').hide(); $("#theyellow").click(function() { $('#map').show();sepysfunction(); }); });//end</script><script type="text/javascript"> function sepysfunction() { //sepysfunction//sepysfunction//sepysfunction//sepysfunction//sepysfunction var mapDiv = document.getElementById('map');var latlng = new google.maps.LatLng(37.09, -95.71); var options = { center: latlng, zoom: 4, mapTypeId: google.maps.MapTypeId.ROADMAP}; var map = new google.maps.Map(mapDiv, options); /****************************************************/if(document.forms[0].physichaladdress.value != "") { geocoder = new google.maps.Geocoder();var geocoderRequest = { address: document.forms[0].physichaladdress.value } geocoder.geocode(geocoderRequest, function(results, status) {/////////////////////////////////////////////////////////////if(status == google.maps.GeocoderStatus.OK) {map.setCenter(results[0].geometry.location);map.setZoom(14);getData(document.forms[0].physichaladdress.value);}////////////////////////////////////////////////////////////}); }/******************************************************/ }//sepysfunction//sepysfunction//sepysfunction//sepysfunction//sepysfunction</script> <script type="text/javascript">var thedata; function getData(str) { if (str.length==0) {return;}if (window.XMLHttpRequest) {xmlhttp=new XMLHttpRequest();}else {xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");} ////////////////////////////////////////////////////////xmlhttp.onreadystatechange=function() {if (xmlhttp.readyState==4 && xmlhttp.status==200) {thedata=xmlhttp.responseText;} }/////////////////////////////////////////////////////// xmlhttp.open("GET","getdata.php?q="+str,true);xmlhttp.send();}</script><style>body { font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: small; background: #fff; }#map { width: 100%; height: 500px; border: 1px solid #000; }</style></head><body><form name="mymapgetter"><h3>Enter your physichal address:</h3><input type="text" name="physichaladdress" value="" style="width: 99.5%; margin-left: .25%; margin-right: .25%;"></input><input type="button" id="theyellow" value="getmap" style="width: 100%"></input></form><div id="map"></div><p>To add or comment on locations contact webmaster@wirelessinternetlocations.com</p></body></html> This however breaks the whole program: <!DOCTYPE html><html><head><title>My Title</title><script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script><script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script><script>$(document).ready(function(){ $('#map').hide(); $("#theyellow").click(function() { $('#map').show();sepysfunction(); }); });//end</script><script type="text/javascript"> //GLOBALSvar mapDiv = document.getElementById('map');var latlng = new google.maps.LatLng(37.09, -95.71); var options = { center: latlng, zoom: 4, mapTypeId: google.maps.MapTypeId.ROADMAP}; var map = new google.maps.Map(mapDiv, options);//GLOBALS function sepysfunction() { //sepysfunction//sepysfunction//sepysfunction//sepysfunction//sepysfunction /****************************************************/if(document.forms[0].physichaladdress.value != "") { geocoder = new google.maps.Geocoder();var geocoderRequest = { address: document.forms[0].physichaladdress.value } geocoder.geocode(geocoderRequest, function(results, status) {/////////////////////////////////////////////////////////////if(status == google.maps.GeocoderStatus.OK) {map.setCenter(results[0].geometry.location);map.setZoom(14);getData(document.forms[0].physichaladdress.value);}////////////////////////////////////////////////////////////}); }/******************************************************/ }//sepysfunction//sepysfunction//sepysfunction//sepysfunction//sepysfunction</script> <script type="text/javascript">var thedata; function getData(str) { if (str.length==0) {return;}if (window.XMLHttpRequest) {xmlhttp=new XMLHttpRequest();}else {xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");} ////////////////////////////////////////////////////////xmlhttp.onreadystatechange=function() {if (xmlhttp.readyState==4 && xmlhttp.status==200) {thedata=xmlhttp.responseText;} }/////////////////////////////////////////////////////// xmlhttp.open("GET","getdata.php?q="+str,true);xmlhttp.send();}</script><style>body { font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: small; background: #fff; }#map { width: 100%; height: 500px; border: 1px solid #000; }</style></head><body><form name="mymapgetter"><h3>Enter your physichal address:</h3><input type="text" name="physichaladdress" value="" style="width: 99.5%; margin-left: .25%; margin-right: .25%;"></input><input type="button" id="theyellow" value="getmap" style="width: 100%"></input></form><div id="map"></div><p>To add or comment on locations contact webmaster@mydomain.com</p></body></html> I don't understand why the program breaks. The modifications I made are intended to make those variables global so they can be accessed by other functions. Does anyone know what is going on?
×