Jump to content

Search the Community

Showing results for tags 'parameters'.

  • 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

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Languages

Found 3 results

  1. BACKGROUND: Please find below a portion of a PHP class used to create an RSS feed. Included are only the constructor function and the function used to create the actual document. All other functions have been omitted so as to focus on the question at hand. My reason for posting this code is to better understand the proper way to create a class. As you can readily see from the __construct( ) function of this class each new instance of the class requires six parameter values. Although the author lists these parameters at the beginning of the class definition, he comments them out, rather than initializing them. QUESTION: Is this standard practice? What is to be gained by not declaring them outside of the __construct( ) function? It appears to create an unnecessary repetitious use of the pseudo $this variable. <?php /** * rss_feed (simple rss 2.0 feed creator php class) * * @author Christos Pontikis http://pontikis.net * @copyright Christos Pontikis * @license MIT http://opensource.org/licenses/MIT * @version 0.1.0 (28 July 2013) * */ class rss_feed { /** * Constructor * * @param array $a_db database settings * @param string $xmlns XML namespace * @param array $a_channel channel properties * @param string $site_url the URL of your site * @param string $site_name the name of your site * @param bool $full_feed flag for full feed (all topic content) */ public function __construct($a_db, $xmlns, $a_channel, $site_url, $site_name, $full_feed = false) { // initialize $this->db_settings = $a_db; $this->xmlns = ($xmlns ? ' ' . $xmlns : ''); $this->channel_properties = $a_channel; $this->site_url = $site_url; $this->site_name = $site_name; $this->full_feed = $full_feed; } /** * Generate RSS 2.0 feed * * @return string RSS 2.0 xml */ public function create_feed() { $xml = '<?xml version="1.0" encoding="utf-8"?>' . "\n"; $xml .= '<rss version="2.0"' . $this->xmlns . '>' . "\n"; // channel required properties $xml .= '<channel>' . "\n"; $xml .= '<title>' . $this->channel_properties["title"] . '</title>' . "\n"; $xml .= '<link>' . $this->channel_properties["link"] . '</link>' . "\n"; $xml .= '<description>' . $this->channel_properties["description"] . '</description>' . "\n"; // channel optional properties if(array_key_exists("language", $this->channel_properties)) { $xml .= '<language>' . $this->channel_properties["language"] . '</language>' . "\n"; } if(array_key_exists("image_title", $this->channel_properties)) { $xml .= '<image>' . "\n"; $xml .= '<title>' . $this->channel_properties["image_title"] . '</title>' . "\n"; $xml .= '<link>' . $this->channel_properties["image_link"] . '</link>' . "\n"; $xml .= '<url>' . $this->channel_properties["image_url"] . '</url>' . "\n"; $xml .= '</image>' . "\n"; } // get RSS channel items $now = date("YmdHis"); // get current time // configure appropriately to your environment $rss_items = $this->get_feed_items($now); foreach($rss_items as $rss_item) { $xml .= '<item>' . "\n"; $xml .= '<title>' . $rss_item['title'] . '</title>' . "\n"; $xml .= '<link>' . $rss_item['link'] . '</link>' . "\n"; $xml .= '<description>' . $rss_item['description'] . '</description>' . "\n"; $xml .= '<pubDate>' . $rss_item['pubDate'] . '</pubDate>' . "\n"; $xml .= '<category>' . $rss_item['category'] . '</category>' . "\n"; $xml .= '<source>' . $rss_item['source'] . '</source>' . "\n"; if($this->full_feed) { $xml .= '<content:encoded>' . $rss_item['content'] . '</content:encoded>' . "\n"; } $xml .= '</item>' . "\n"; } $xml .= '</channel>'; $xml .= '</rss>'; return $xml; } } ?>
  2. var xmlhttp; var Staff, obj; var url = "staff.json"; function init() { xmlhttp = (window.XMLHttpRequest) ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP") ? new ActiveXObject("Msxml2.XMLHTTP") : null ; xmlhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { Staff = JSON.parse(this.responseText); var table = document.createElement("table"); document.body.appendChild(table); obj = Staff.Staff[0]; for (var y in obj) { var header_row = document.createElement("th"); var column = document.createElement("td"); var data = document.createTextNode(y); column.appendChild(data); header_row.appendChild(column); table.appendChild(header_row); } for(var x=0; x<Staff.Staff.length; x++) { obj = Staff.Staff[x]; if (x%2 == 0) { var row = document.createElement("tr"); row.setAttribute("class","even"); // function? for (var y in obj) { var column = document.createElement("td"); var data = document.createTextNode(obj[y]); column.appendChild(data); row.appendChild(column); table.appendChild(row); } } else { var row = document.createElement("tr"); // function? for (var y in obj) { var column = document.createElement("td"); var data = document.createTextNode(obj[y]); column.appendChild(data); row.appendChild(column); table.appendChild(row); } } } } }; xmlhttp.open("GET",url,true); xmlhttp.send(); } window.onload = init; Since the codes below "// function?" are repeated (either the row to be created in the JavaScript is odd or even), how can I write the same codes into ONE function to be shared and used in different places? Thanks for any help!
  3. I was able to complete a live search with a T-SQL database similar to the design found here on W3Schools, though now I am running into some difficulties passing multiple arguments/parameters to the JavaScript search page. Basically, we thought it would be a good idea to let people search by just a first name or last name if they wanted, as well as searching by their affiliation. Here is an excerpt from the form that appears to be giving me the problems: <form><input type="text" name="name" id="nameID" size="40" maxlength="64" onKeyUp="showNames('nameID', 'typeID', 'firstLastID')"onblur="if (this.value == '') this.value = this.defaultValue" onFocus="if (this.value == this.defaultValue) this.value = ''"value="Enter a name or a part of a name here"> <br><select name="type" id="typeID" onChange="showNames('nameID', 'typeID', 'firstLastID')"><option value="All">Members & Staff</option><option value="Member">Member</option><option value="Staff">Staff</option></select> <br><select name="firstLast" id="firstLastID" onChange="showNames('nameID', 'typeID', 'firstLastID')"><option value="Both">First & Last Name</option><option value="First">First Name</option><option value="Last">Last Name</option></select></form> Right now the form is passing the literal names of nameID, typeID, and firstLastID when I echo the variables in a separate PHP file. I've tried single quotes (which gives the literal names), double quotes (does not work), and no quotation marks (does not work) around the arguments just to see if that was the culprit, but no luck there. Before using the ID's I had been using "this.value", though unfortunately I couldn't use that any longer once we added the additional arguments to showNames(). Finally, I tried removing all of the arguments from showNames() and collecting the data using "document.getElementByID('...').value" (where '...' is the ID) in the JavaScript function, but that didn't work either. Can anyone help me figure this out? Thank you!
×
×
  • Create New...