Jump to content

Destramic

Members
  • Posts

    969
  • Joined

  • Last visited

Everything posted by Destramic

  1. hey guys working on a select/deselect all script and im having a few teething problem...bassically when you load the page the script works fine...but when i checkbox is checked/uncheck the function needs to be ran to return new output...but im having a probelm doing this...help please? <!DOCTYPE html> <html> <head> <script type="text/javascript" src="/ajax/jquery/libary/jquery.js"></script> <script> $(document).ready(function(){ function toggleCheckboxes(group, element, status){ group = $('input[name='+ group +']'); element = $('#'+ element +''); status = $('#'+ status +''); var group_checkbox_count = $(group).length; var group_checked_count = $(''+ group + ':checked').length; var selected = ('(' + group_checked_count + ' out of ' + group_checkbox_count + ' selected)'); $(status).text(selected); if ($(element).text() == '') { if (group_checked_count/group_checkbox_count < 1) { $(element).text('Select All'); } else{ $(element).text('Deselect All'); } } } $(":checkbox").click(toggleCheckboxes()); toggleCheckboxes('sports', 'selectbutton', 'selected'); }); </script> </head> <body> <form> <span id="selectbutton"></span><br/> <span id="selected"></span><br/><br/> Soccer: <input type="checkbox" name="sports" value="soccer" /><br /> Football: <input type="checkbox" name="sports" value="football" checked /><br /> Baseball: <input type="checkbox" name="sports" value="baseball" /><br /> Basketball: <input type="checkbox" name="sports" value="basketball" /> </form> </body> </html>
  2. thanks...well ive almost finished my script...but im having a problem when loading this script public function set_cookies() { $time = time() + 3600 * 24 * $this->cookie_expiry_day; $domain = $_SERVER['SERVER_ADDR']; setcookie ("user_id", $this->user_id, $time, "/", $domain, true, false); setcookie ("username", $this->username, $time, "/", $domain, true, false); setcookie ("password", $this->password, $time, "/", $domain, true, false); setcookie ("email", $this->email, $time, "/", $domain, true, false); setcookie ("user_access", $this->user_access, $time, "/", $domain, true, false); } Warning: Cannot modify header information - headers already sent by (output started at C:\www\auth.php:15) in C:\www\classes\Authentication.php on line 185 Warning: Cannot modify header information - headers already sent by (output started at C:\www\auth.php:15) in C:\www\classes\Authentication.php on line 186 Warning: Cannot modify header information - headers already sent by (output started at C:\www\auth.php:15) in C:\www\classes\Authentication.php on line 187 Warning: Cannot modify header information - headers already sent by (output started at C:\www\auth.php:15) in C:\www\classes\Authentication.php on line 188 Warning: Cannot modify header information - headers already sent by (output started at C:\www\auth.php:15) in C:\www\classes\Authentication.php on line 189 do you know any reason why this is happening please?
  3. ok thanks that was a great help...one last thing what is the function session_id(); used for...i know it returns a unique code...but how and where is the function used?
  4. Yes I mean unset is this the best way to destroy the sessions and cookies?...and thank you for your reply
  5. hey guys im the middle of making a login script but i have a few questions about cookies and sessions if anyone can help please 1. is the best way to use uset() the session/cookie? 2. also when set_cookie(); the parameter path what should this be set at?...im a bit confused 3. do i need to set any headers also? other than setting the header location? thanks destramic
  6. well you could start with removing the comment tags on //$count=mysql_num_rows($result); to: $count=mysql_num_rows($result); see how you get on with that....if no luck echo $count just below and see what value you get...post back if any problems
  7. hey guys im after a benchmarking tutorial of some kind so i can write i script for both php and mysql if someone can point me in the right direction then i would be very greatful...thank you
  8. thanks you for your reply and help
  9. Destramic

    php eregi

    hey guys im need to be able to see if a string contains a certian character :1 or :2 etc...it will be a colon then a number i know it needs to be done by using eregi but im not sure on how to do it if anyone can help please...thanks alot
  10. hey guys i have made a json script but i have data from mysql database that i need to convert to json...does anyone have a good tutorial/class/function on how this could be done correctley please thanks destramic
  11. hey guys im trying to make a select all checkboxes (grouped) script...my problem im having is that var group_checked_count = $('group:checked').length; var group_count = $(group).length; isnt returning the correct value as they both are returning 0 var group_checked_count should return 1...and var group_count should return 4 it seems im doing something wrong...if anyone could point out what that is please <!DOCTYPE html> <html> <head> <script type="text/javascript" src="/ajax/jquery/libary/jquery.js"></script> <script> function toggleCheckboxes(group, element) { group = $('input[name='+ group +']'); element = $('#'+ element +''); var group_checked_count = $('group:checked').length; var group_count = $(group).length; if ($(element).text() == '') { if ($(group_count) / $(group_checked_count) < 1) { $(element).text() = 'Select All'; } else{ $(element).text() = 'Deselect All'; } } } toggleCheckboxes('sports', 'selectbutton'); </script> </head> <body> <form> <span id="selectbutton"></span> Soccer: <input type="checkbox" name="sports" value="soccer" /><br /> Football: <input type="checkbox" name="sports" value="football" checked /><br /> Baseball: <input type="checkbox" name="sports" value="baseball" /><br /> Basketball: <input type="checkbox" name="sports" value="basketball" /> </form> </body> </html>
  12. is it good practice to include where nessesary or just simple " " just leave a space...the reason i ask this is because i know some browsers render this differently and as stupid as the question may be im wondering if to us or just start using a " " space? thanks destramic
  13. thats great thanks ken
  14. hello...i have a while loop which works fine but i want to count and every 5th loop have a break (<br />)....im just wondering on the best way of doing is...i have on method...but i'm thinking there may be a better way of doing it than the way i am? <?php $i = 0; while ($games_row = mysql_fetch_array($games_result, MYSQL_BOTH)) { if ($i =5 ) { echo "<br />"; $i = 0; } printf ("<option value=\"\">%s</option>\n", $game_name); $i++; } ?> thanks
  15. dj kat....all code posted were from json.php...just updat ed versions...although ive now got my script working as i want it...and as for the ob_clean, ob_start and die....without these functions my script wouldnt work....by all means have a look <?php ob_start(); ?> <!DOCTYPE html> <html> <head> <script type="text/javascript" src="/ajax/jquery/libary/jquery.js"></script> </head> <body> <?php if ($_POST['game'] == 1) { $array = array( 'game_type' => array( array('value' => 1, 'text' => 'CTF'), array('value' => 1, 'text' => 'TDM'), ), 'division' => array( array('value' => 1, 'text' => 'Division 1'), array('value' => 1, 'text' => 'Division 2') )); ob_clean(); header('Content-Type: application/json'); die(json_encode($array)); } elseif ($_POST['game'] == 2) { $array = array( 'game_type' => array( array('value' => 1, 'text' => 'TKOTH'), array('value' => 1, 'text' => 'DM'), ), 'division' => array( array('value' => 1, 'text' => 'Division 3'), array('value' => 1, 'text' => 'Division 4') )); ob_clean(); header('Content-Type: application/json'); die(json_encode($array)); } ?> <form> <script> $(document).ready(function(){ var game_type_value = $('#game_type').text(); var division_value = $('#division').text(); $("#game").change(function() { if ($('#game option:selected').text() == "") { $('#game_type').empty(); $('#division').empty(); $('#game_type').text(game_type_value); $('#division').text(division_value); } var post_string = "game=" + $(this).val(); $.ajax({ type: 'POST', data: post_string, cache: false, dataType: 'json', url: 'json.php', timeout: '2000', error: function(data) { console.log(data); }, success: function(data) { $.each(data, function(prop, obj){ switch(prop) { case 'game_type': $('#game_type').empty(); $.each(obj, function(i, val){ var game_type_row =$('<label>' + val.text +'</label><input name=\"\" id=\"\" type=\"checkbox\" value=\"'+ val.value +'\" />'); $(game_type_row).appendTo('#game_type'); }); break; case 'division': $('#division').empty(); $.each(obj, function(i, val){ var division_row = $('<label>' + val.text +'</label><input name=\"\" id=\"\" type=\"checkbox\" value=\"'+ val.value +'\" />'); $(division_row).appendTo('#division'); }); break; } }); } }); }); }); </script> <select name="game" id="game"> <option value=""></option> <option value="1">Counter Strike</option> <option value="2">COD</option> </select> <div id="game_type"> please select a game...</div> <div id="division"> please select a game...</div> </form> </body> </html> but there is one question i need to have two clauses in the line $("#game").change(function() { something like $("#game").change || $("#game").text(function() { but im not sure how this is done...as im still leaning...if anyknow how this is possible please let me know....thank you
  16. here you go dj kat...i've been working on this for the last couple of days...just having a problem returning the objects in the array...maybe a second pair of eyes could notice the problem...thanks <?php ob_start(); ?> <!DOCTYPE html> <html> <head> <script type="text/javascript" src="/ajax/jquery/libary/jquery.js"></script> </head> <body> <?php if ($_POST['game'] == 1) { $array = array( 'game_type' => array( array('value' => 1, 'text' => 'CTF'), array('value' => 1, 'text' => 'TDM'), ), 'division' => array( array('value' => 1, 'text' => 'Division 1'), array('value' => 1, 'text' => 'Division 2') )); ob_clean(); header('Content-Type: application/json'); die(json_encode($array)); } elseif ($_POST['game'] == 2) { $array = array( 'game_type' => array( array('value' => 1, 'text' => 'TKOTH'), array('value' => 1, 'text' => 'DM'), ), 'division' => array( array('value' => 1, 'text' => 'Division 3'), array('value' => 1, 'text' => 'Division 4') )); ob_clean(); header('Content-Type: application/json'); die(json_encode($array)); } ?> <form> <script> $(document).ready(function(){ $("#game").change(function(){ var post_string = "game=" + $(this).val(); $.ajax({ type: 'POST', data: post_string, cache: false, dataType: 'json', url: 'json.php', timeout: '2000', error: function(data) { console.log(data); }, success: function(data) { $.each(data, function(prop, obj){ switch(prop) { case 'game_type': $.each(obj, function(i, val){ var game_type_row = val.text + '<input name=\"\" id=\"\" type=\"checkbox\" value=\"' + val.value + '\" />\n'; console.log(game_type_row); $(game_type_row).appendTo('#game_type'); }); break; case 'division': $.each(obj, function(i, val){ var division_row = val.text +'<input name=\"\" id=\"\" type=\"checkbox\" value=\"'+ val.value +'\" />\n'; console.log(division_row); $(division_row).appendTo('#division'); }); break; } }); } }); }); }); </script> <select name="game" id="game"> <option value=""></option> <option value="1">Counter Strike</option> <option value="2">COD</option> </select> <div id="game_type"> please select a game...</div> <div id="division"> please select a game...</div> </form> </body> </html>
  17. ive done it now...thanks again
  18. yes i have a router...should i put the ip then the port and forward that?....also do i need to edit any setting for apache? thanks
  19. im not sure if this is the right place to post this...but im looking for tutorial on how to make my apache server pubic so peple can view my pages through my ip address...if somene could help that would be great. thanks
  20. hey guys im having a problem returning the data in the json array...plus when alerting data.value it comes back at 1000+ which is truely incorrect....can anyone explain where i am going wrong please?...thank you <!DOCTYPE html> <html> <head> <script type="text/javascript" src="/ajax/jquery/libary/jquery.js"></script> </head> <body> <?php $game_type = array(); $division = array(); if ($_POST['game'] == 1) { $game_type[] = array('value' => '1', 'text' => 'TDM' ); $game_type[] = array('value' => '1', 'text' => 'CTF' ); $division[] = array('value' => '1', 'text' => 'Divison 1' ); } elseif ($_POST['game'] == 2) { $game_type[] = array('value' => '1', 'text' => 'CTF' ); $division[] = array('value' => '1', 'text' => 'Divison 2' ); } json_encode($game_type); json_encode($division); ?> <form> <script> $(document).ready(function(){ $("select#game").change(function(){ var post_string = "game=" + $(this).val(); $.ajax({ type: 'POST', data: post_string, cache: false, dataType: 'game_type', url: 'json.php', timeout: '2000', error: function() { alert("Error has occured"); }, success: function(data) { alert(data.length); alert(data[1].text); } }); }); }); //$('#game_type').html('<input type=\"checkbox\" value=\"test\" /> TDM'); //$('#division').html('<input type=\"checkbox\" value=\"test\" /> Division 1'); </script> <select name="game" id="game"> <option value=""></option> <option value="1">Counter Strike</option> <option value="2">COD</option> </select> <div id="game_type"> </div> <div id="division"> </div> <select name="sub_category" id="sub_category"> <option value="">-- Select First Value --</option> </select> </form> </body> </html>
  21. thanks haku...after a bit of playing around i found out the problem...thanks again
  22. thanks for your reply...i just tried the float and it just puts both labels and checkboxes on different columns and not the same one...any other ideas?
  23. im finnal on to something now...but the script im trying to function keeps returning an error on the json "failed to submit"...can anyone tell me why please <!DOCTYPE html> <html> <head> <script type="text/javascript" src="/ajax/jquery/libary/jquery.js"></script> </head> <body> <?php $game_type = array(); $division = array(); if ($_POST['game'] == 1) { $game_type[] = array('value' => '1', 'text' => 'TDM' ); $division[] = array('value' => '1', 'text' => 'Divison 1' ); } elseif ($_POST['game'] == 2) { $game_type[] = array('value' => '1', 'text' => 'CTF' ); $division[] = array('value' => '1', 'text' => 'Divison 2' ); } json_encode($game_type); json_encode($division); ?> <form> <script> $(document).ready(function(){ $("select#game").change(function(){ $.ajax({ type: 'POST', data: 'data', dataType: 'json', cache: false, url: 'json.php', timeout: '2000', error: function() { alert("Failed to submit"); }, success: function(data) { alert("working!"); } }); // $('#game_type').html('<input type=\"checkbox\" value=\"test\" /> TDM'); // $('#division').html('<input type=\"checkbox\" value=\"test\" /> Division 1'); }); }); </script> <select name="game" id="game"> <option value=""></option> <option value="1">Counter Strike</option> <option value="2">COD</option> </select> <div id="game_type"> </div> <div id="division"> </div> </form> </body> </html>
  24. hey guys im trying to get multiple checkboxes on a line without the label dropping down on another line...if anyone can help please css label { width: 100px; float:left; display: inline;} input[type="checkbox"] { padding:6px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; } html <label for="Neatherlands">Neatherlands</label> <input type="checkbox" name="neatherlands" id="Neatherlands" value="" /> <label for="United Kingdom">United Kingdom</label> <input type="checkbox" name="united kingdom" id="United Kingdom" value="" />
×
×
  • 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.