Welcome! Log In Create A New Profile

Advanced

jQuery allowed?

Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
avatar jQuery allowed?
February 12, 2013 10:57AM
Are we allowed to use jQuery? I would like to use it for ajax and for manipulating the HTML in real-time without having to reload the page so many times.

a sample of the kind of thing I would like to do there looks like this. This is part of the system I'm writing at work, this code is copyrighted so no copying it from me!

Language: Javascript
<script type="text/javascript"> //confirm not safe function checkForm() { if($(';input:radio[name=safe]:checked';).val() == ';no';) { return confirm("Are you sure this item is NOT safe to use?"); } } $(document).ready(function(){ var assetno = ""; //get the info for the asset children and output $("#asset_num").bind("change", function(){ assetno = $(';#asset_num option:selected';).text();   $.post("./asset_child_info.php",{asset: assetno},function(data){ var vals = new Array(); var untrimed = new Array(); untrimed = data.split(",");   for(var i=0; i < untrimed.length; i++) { vals[i] = $.trim(untrimed[i]); } //output children $("#children").hide(); $("#children").empty(); var childrenList = "All these items have to be present:<br /><ol>"; for(var i=0; i < vals.length; i++) { childrenList = childrenList + "<li>" + vals[i] + "</li>"; } childrenList = childrenList + "</ol>"; $("#children").append(childrenList); $("#children").fadeIn(';fast';);   }); }); });//end main func   </script>

The server side:

Language: PHP
<?php include(';../../../bin/config/coninfo.php';); $con = mysql_connect($server, $usrname, $pwd); if(!$con) { die(';Could not connect: '; . mysql_error()); }   $asset = xssFilter($_POST[';asset';]); $retstring = "";   mysql_select_db(';ndms_admin';, $con);   $query = "SELECT name FROM equipment_new WHERE assetcode=';{$asset}'; AND name!=';MAIN UNIT';";   $result = mysql_query($query);   while($row = mysql_fetch_array($result)) { $retstring .= $row[';name';] . ","; }   //remove last comma $retstring = substr_replace($retstring ,"",-1);   echo $retstring;

This gets the asset children from the database and displays them in a div without reloading the page. I would like to do something similar with the deleting a player section. I have some cool ideas there.

----------------------------------------------------------------------------------------

int get_random_number() {
return 4;
}
avatar
Mac
Re: jQuery allowed?
February 12, 2013 11:35AM
You can use jquery yes..... Just not php frameworks.
avatar Re: jQuery allowed?
February 12, 2013 11:42AM
Awesome! Thanks, I promise, no php frameworks. smile

----------------------------------------------------------------------------------------

int get_random_number() {
return 4;
}
Sorry, only registered users may post in this forum.

Click here to login