PHP - My First Attempt At Ajax, Empty Array
What I am trying to do is to submit as POST values to database_write.php, from within the while statement. What is happening is I am getting the second row of data every time I change the primary button.
Currently database_write.php is just doing print_r($_POST), And my array is always the same, no matter which select box I choose from. How can I get the values to be associated with the row I am currently changing? Any help would be great, thanks.
What I have so far:
<table class="table table-bordered table-hover"> <thead> <th>Room Number</th> <th>Primary Caregiver</th> <th>Seconday Caregiver</th> </thead> <tbody class="list"> <?php $sql = 'SELECT alarm_device_id, alarm_description, alarm_device_type, notes FROM alarm_device where notes in (\'MSU\') ORDER BY alarm_description'; $retval = mysql_query( $sql, $con ); if(! $retval ) { die('Could not get data: ' . mysql_error()); } $x=0; while($row = mysql_fetch_array($retval, MYSQL_ASSOC)) { $id = $row['alarm_device_id']; $alarm_description = $row['alarm_description']; echo '<form id="msu_form">'; echo "<tr><td>{$row['alarm_description']}</td>"; echo "<td>"; $query2 = "SELECT alert_device_id,alert_description FROM alert_device WHERE notes = 'MSU'"; $result2 = mysql_query($query2) or die("Error in alarm_device select:" . mysql_error()); $count2 = mysql_num_rows($result2); if($count2 > 0) { //echo '<select name='.$x.'>'; echo '<select id="Primary" name="primary" onchange="doAjaxPost(this)">'; while($row2 = mysql_fetch_array($result2)) { echo "<option value=".$row2['alert_device_id'].">".$row2['alert_description']."</option>"; } echo "</select>"; }else { echo "Please update alert device to this area"; } echo "</td>"; echo "<td>"; $query3 = "SELECT alert_device_id,alert_description FROM alert_device WHERE notes = 'MSU2'"; $result3 = mysql_query($query3) or die("Error in alarm_device select:" . mysql_error()); $count3 = mysql_num_rows($result3); if($count3 > 0) { echo '<select id="Secondary" name="secondary">'; while($row3 = mysql_fetch_array($result3)) { echo "<option value=".$row3['alert_device_id'].">".$row3['alert_description']."</option>"; } echo "</select>"; }else { echo "Please update alert device to this area"; } echo "</td>"; $aid = $id + $x; //echo $aid; //$ad = $alarm_description + $x; echo '<input type="hidden" id="ID" name="ID" value="'.$id.'"/>'; //echo '<input type="hidden" id="desc" name="desc" value="'.$ad.'"/>'; //echo '<td>'."<input type='submit' name='btnupdate' value='UPDATE' /></td>"; //echo '<td><input type="button" value="Ajax Request" onClick="doAjaxPost()"></td>'; echo '</form>'; $x = $x+1; } ?> <script> function doAjaxPost() { // get the form values var primary = $('#Primary').val(); var secondary = $('#Secondary').val(); var hidden = $('#ID').val(); //var desc = $(sel).parent().nextAll('#desc').val(); $.ajax({ type: "POST", url: "functions/database_write.php", data: $('#msu_form').serialize(), //data: "Primary="+primary+"&Hidden="+hidden+"&Secondary="+secondary, success: function(resp){ //we have the response alert("'" + resp + "'"); }, error: function(e){ alert('Error: ' + e); } }); } </script> </tr> </tbody> </table> Similar TutorialsThis topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=328006.0 I am using a script to take postcodes and give distances between them and list all postcodes within a radius. Where it should list all the postcodes in the radius it provides and empty array - any clues?? the table is 'geodb' relevant fields are postcode place latitude longitude and the code is Code: [Select] if(isset($_GET['Search'])) { $postcode = strtoupper($_GET['postcode']); $radius = $_GET['radius']; echo $postcode . '<br>'; echo $radius . '<br>'; $conn = mysql_connect(/*credentials removed*/) or die('db connect error: ' . mysql_error()); mysql_select_db('db379121', $conn) or die('could not select database'); $sqlstring = "SELECT * FROM geodb WHERE postcode = '".$postcode."'"; $result = mysql_query($sqlstring); $row = mysql_fetch_assoc($result); ++++++++++++++++++++++++++++++++++++++++++ var_dump($row); // seeing whqat is in the array - returns one result (array(9) { ["id"]=> string(1) "1" ["countrycode"]=> string(2) "GB" ["postcode"]=> string(4) "AB10" ["place"]=> string(8) "Aberdeen" ["postaltown"]=> string(8) "Aberdeen" ["region1"]=> string(8) "Scotland" ["region2"]=> string(13) "Aberdeen City" ["latitude"]=> string(12) "57.135813090" ["longitude"]=> string(12) "-2.121224030" })// ++++++++++++++++++++++++++++++++++++++++++ $lng = $row["longitude"] / 180 * M_PI; $lat = $row["latitude"] / 180 * M_PI; echo $lat . '<br>'; echo $lng . '<br>'; ++++++++++++++++++++++++++++++++++++++++++ echo to check that there is a value here - i get lat 0.99720805922458 lng -0.037022343495923 ++++++++++++++++++++++++++++++++++++++++++ mysql_free_result($result);} $sqlstring2 = "SELECT DISTINCT geodb.postcode,geodb.place,(6367.41*SQRT(2*(1-cos(RADIANS(geodb.latitude))*cos(".$lat.")*(sin(RADIANS(geodb.longitude))*sin(".$lng.")+cos(RADIANS(geodb.longitude))*cos(".$lng."))-sin(RADIANS(geodb.latitude))* sin(".$lat.")))) AS Distance FROM geodb AS geodb WHERE (6367.41*SQRT(2*(1-cos(RADIANS(geodb.latitude))*cos(".$lat.")*(sin(RADIANS(geodb.longitude))*sin(".$lng.")+cos(RADIANS(geodb.longitude))*cos(".$lng."))-sin(RADIANS(geodb.latitude))*sin(".$lat."))) <= '".$distance."') ORDER BY Distance"; $result = mysql_query($sqlstring2) or die('query failed: ' . mysql_error()); $str = "<table width=\"300\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"; $str .= "<tr>"; $str .= "<th>postcode</th>"; $str .= "<th>city</th>"; $str .= "<th>distance</th>"; $str .= "</tr>"; while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $str .= "<tr><td>".$row["postcode"]."</td><td>".$row["place"]."</td><td>".round($row['Distance'])."km</td></tr>"; } $str .= "</table>"; ++++++++++++++++++++++++++++++++++++++++++ var_dump($row["place"]); // this produces null ++++++++++++++++++++++++++++++++++++++++++ mysql_free_result($result); mysql_close($conn); echo $str; Is there a built in function to remove empty array values for example: change Array ( [0] => Bob [1] => [2] => Ryan [3] => Jane ) to Array ( [0] => Bob [1] => Ryan [2] => Jane ) Thanks Hey guys i am currently building a very complex form for one of my clients. The for has ALOT of imputs and can also generate new one automaticly using javascript. My problem is that come of them returns empty arrays while other works. Is there a maximum or some kind that a form can submit at the time? i made a print_r on the $_POST var and this is what i got (I tooke out all the other arrays but theres a lot more then what i am posting) [...] print ('<tr> <td> <input type="text" size="9" name="styleenc[]" value=""> </td> <td> <input type="text" size="9" name="couleurenc[]" value=""> </td> <td> <input type="text" size="2" name="c_y[]" value=""> </td> <td> <input type="text" size="2" name="c_a_s[]" value=""> </td> <td> <input type="text" size="2" name="c_a_l[]" value=""> </td> <td> <input type="text" size="2" name="c_a_o_s[]" value=""> </td> <td> <input type="text" size="9" name="descenc[]" value=""> <input type="hidden" size="9" name="invisible3[]" value="3"> </td> </tr>'); [...] Code: [Select] Array ( [styleenc] => Array ( [0] => [1] => [2] => [3] => [4] => ) [couleurenc] => Array ( [0] => [1] => [2] => [3] => [4] => ) [c_y] => Array ( [0] => [1] => [2] => [3] => [4] => ) [c_a_s] => Array ( [0] => [1] => [2] => [3] => [4] => ) [c_a_l] => Array ( [0] => [1] => [2] => [3] => [4] => ) [c_a_o_s] => Array ( [0] => [1] => [2] => [3] => [4] => ) [descenc] => Array ( [0] => [1] => [2] => [3] => [4] => ) [invisible3] => Array ( [0] => 3 [1] => 3 [2] => 3 [3] => 3 [4] => 3 ) [emplacement] => sdcwedf ) They should all have values i don't get it ... the only one that has values is invisible3 that has been manualy specified with value="3" I want to merge some arrays as Code: [Select] $mixing = array_merge($mixedresult1, $mixedresult2, $mixedresult3);but the arrays can be empty sometimes. In this case, I will get an error for the empty array as Code: [Select] PHP Warning: array_merge() [<a href='function.array-merge'>function.array-merge</a>]: Argument #1 is not an arrayHow I can avoid this error by omitting empty arrays? I have the form / script below that works to add multiple rows of data with one query. One thing I did not think about is what if the first set of form fields are filled and the second is not. Currently the script insert an empty row. I'm sure how I would go about checking for an empty row and if there is an empty row ignore it and do not put it in the DB. Can someone point me in the right direction? Code: [Select] <?php // Begin the script for this page if (isset($_POST['submit'])) { //Assign each array to a variable $id = $_POST['id']; $store = $_POST['store']; $item = $_POST['item']; $itemprice = $_POST['itemprice']; $itemnumber = $_POST['itemnumber']; $couponvalue = $_POST['couponvalue']; $couponsused = $_POST['couponsused']; $limit = count($id); $values = array(); // initialize an empty array to hold the values for($i=0;$i<$limit;$i++){ $store[$i] = check_input($store[$i]); $item[$i] = check_input($item[$i]); $itemprice[$i] = check_input($itemprice[$i]); $itemnumber[$i] = check_input($itemnumber[$i]); $couponvalue[$i] = check_input($couponvalue[$i]); $couponsused[$i] = check_input($couponsused[$i]); $values[$i] = "( '{$id[$i]}', '{$store[$i]}', '{$item[$i]}', '{$itemprice[$i]}', '{$itemnumber[$i]}', '{$couponvalue[$i]}', '{$couponsused[$i]}')"; // build the array of values for the query string } $query = "INSERT INTO `item` (user_id, store, item, itemprice, itemnumber, couponvalue, couponsused) VALUES " . implode( ', ', $values ); // Form the query string and add the implod()ed values if (!mysql_query($query,$link)){ die('Error: ' . mysql_error()); } else { $added = "Your items have been added."; } } ?> <div class="pageContent"> <div id="main"> <div class="container"> <?php echo $added; if($_SESSION['id']){ echo '<form action="" method="post">'; echo '<table cellpadding= "4">'; echo '<tr>'; echo '<input type="hidden" name="id[]" id="id[]" value='.$_SESSION['id'].' />'; echo '<td><DIV CLASS="p2"><b>Store</b></div>'; echo '<input type="text" name="store[]" id="store[]" size="15" maxlength="255"/></td>'; echo '<td><DIV CLASS="p2"><b>Item</b></div>'; echo '<input type="text" name="item[]" id="item[]" size="15" maxlength="255"/></td>'; echo '<td><DIV CLASS="p2"><b>Item Price</b></div>'; echo '<input type="text" name="itemprice[]" id="itemprice[]" size="5" maxlength="255"/></td>'; echo '<td><DIV CLASS="p2"><b>Item #</b></div>'; echo '<select name="itemnumber[]" id="itemnumber[]"><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option><option value="11">11</option><option value="12">12</option><option value="13">13</option><option value="14">14</option><option value="15">15</option><option value="16">16</option><option value="17">17</option><option value="18">18</option><option value="19">19</option><option value="20">20</option></select></td>'; echo '<td><DIV CLASS="p2"><b>Coupon Value</b></div>'; echo '<input type="text" name="couponvalue[]" id="couponvalue[]" size="10" maxlength="255"/></td>'; echo '<td><DIV CLASS="p2"><b># Coupons</b></div>'; echo '<select style="width: 60px;" name="couponsused[]" id="couponsused[]"><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option><option value="11">11</option><option value="12">12</option><option value="13">13</option><option value="14">14</option><option value="15">15</option><option value="16">16</option><option value="17">17</option><option value="18">18</option><option value="19">19</option><option value="20">20</option></select></td>'; echo '<td><DIV CLASS="p2"><b>Doubled Coupon</b></div>'; echo '<select style="width: 75px;" name="doubledcoupon[]" id="doubledcoupon[]"><option value="1">Yes</option><option value="0">No</option></td>'; echo '</tr>'; echo '<tr>'; echo '<input type="hidden" name="id[]" id="id[]" value="'.$_SESSION['id'].'" />'; echo '<td><input type="text" name="store[]" id="store[]" size="15" maxlength="255"/></td>'; echo '<td><input type="text" name="item[]" id="item[]" size="15" maxlength="255"/></td>'; echo '<td><input type="text" name="itemprice[]" id="itemprice[]" size="5" maxlength="255"/></td>'; echo '<td><select name="itemnumber[]" id="itemnumber[]"><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option><option value="11">11</option><option value="12">12</option><option value="13">13</option><option value="14">14</option><option value="15">15</option><option value="16">16</option><option value="17">17</option><option value="18">18</option><option value="19">19</option><option value="20">20</option></select></td>'; echo '<td><input type="text" name="couponvalue[]" id="couponvalue[]" size="10" maxlength="255"/></td>'; echo '<td><select style="width: 60px;" name="couponsused[]" id="couponsused[]"><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option><option value="11">11</option><option value="12">12</option><option value="13">13</option><option value="14">14</option><option value="15">15</option><option value="16">16</option><option value="17">17</option><option value="18">18</option><option value="19">19</option><option value="20">20</option></select></td>'; echo '<td><select style="width: 75px;" name="doubledcoupon[]" id="doubledcoupon[]"><option value="1">Yes</option><option value="0">No</option></td>'; echo'</tr>'; echo'<tr>'; echo '<input type="submit" name="submit" value="Submit Item">'; echo'</tr>'; echo '</table>'; echo'</form>'; } else { echo '<h1>Please, <a href="index.php">login</a> and come back later!</h1>'; } ?> </div> </div> </div> Hi All, Need help. I'm strugling to figure out how to write the code to display default image if no image is available. I'm able to display image if data is available. Not able figure how to echo if/else statment. Below is the code Code: [Select] <?php function perDetails($var1, $result, $var2){ $dft_img = 'lib/images/name.png'; echo '<div class="desc">'.$var1.'</div>'; $color="1"; echo '<table align="center" cellpadding="2" cellspacing="1">'; while($row = mysql_fetch_array($result)){ $id = $row['pid']; $name = $row['pname']; $img = $row['pphoto_localurl']; $poster = str_replace("./", "lib/", $img); if($color==1){ echo '<tr bgcolor="#FFC600"><td><img src="'.$poster.'" width="32" height="42" alt="'.$name.'"</td><td><a href="persons.php?det='.$var2.'&perid='.$id.'"> '.$name.'" </a></td></tr>'; $color="2"; } else { echo '<tr bgcolor="#C6FF00"><td><img src="'.$poster.'" width="32" height="42" alt="'.$name.'"</td><td><a href="persons.php?det='.$var2.'&perid='.$id.'"> '.$name.'" </a></td></tr>'; $color="1"; } } echo '</table>'; } ?> I am working with the Amazon API, and I am trying to display a default image if a product does not have an image associated with it. The query is coming back as an array. Typically, each product image array looks like this: $d = SimpleXMLElement Object ( http:// => [url]http://ecx.images-amazon.com/images/I/51aUIul6XjL._SL160_.jpg [Height] => 160 [Width] => 112 ) The code goes like this: Code: [Select] if ($d=$E->MediumImage) { $iu=$d->URL; $ih=$d->Height; $iw=$d->Width; echo count($d); if (strlen($iu) > 0) {echo "<center><a href='$url' target='_blank'><img src='images/amazon_noimage.jpg' width='175' height='175' border='0'></a></center>";} else {echo "<center><a href='$url' target='_blank'><img src='$iu' width='$iw' height='$ih' border='0'></a></center>";} } However, images/amazon_noimage.jpg never shows up (even though it is linked correctly, as I've tested this link). I have tried the following: if (strlen($iu) > 0) if (count($iu) > 0) if (strlen($d->URL) > 0) if (count($d->URL) > 0) if (isset($d)) if (!isset($d)) etc ... If I display the following, where there is no image, I get nothing displayed: echo $iu; print_r($iu); echo $d->URL; etc ... However, if there is an image, I get a link, such as the following: http://ecx.images-amazon.com/images/I/51c2BFpDN0L._SL160_.jpg There seems to be NOTHING that I can do to trigger the 'ELSE' part of the if statement. This is a total enigma to me ... any ideas?? Hi
How can limit only required input fields cannot be empty.
<form name="test" method="post" action="test.php"> <label for="quest"> <input type="text" name="quest" /> <!-- REQUIRED --> </label> <label for="answers"> <input type="text" name="answers[]" /> <!-- REQUIRED --> </label> <label for="answers"> <input type="text" name="answers[]" /> <!-- REQUIRED --> </label> <label for="answers"> <input type="text" name="answers[]" /> </label> <label for="answers"> <input type="text" name="answers[]" /> </label> <label for="answers"> <input type="text" name="answers[]" /> </label> <label for="submit"> <input type="submit" name="submit" value="Submit" /> </label> </form>Following function working only on all empty input fields, i need help to enable button when required fields is not empty. $(document).ready(function() { var $submit = $("input[type=submit]"), $inputs = $('input[name=quest], input[name=answers[]]'); function checkEmpty() { // filter over the empty inputs return $inputs.filter(function() { return !$.trim(this.value); }).length === 0; } $inputs.on('keyup', function() { $submit.prop("disabled", !checkEmpty()); }).keyup(); // trigger an initial blur }); Hi, i'm new here and hope i've finally found a forum where i can find the perfect solution for my questions.
Well since a year now i started to work with PHP and still now and then there are some things where i seize on. My question is on of those situations.
I have the following code:
if (isset($_POST)){ foreach ($_POST as $key => $value){ if (!empty($value)){ $update_rma_detail_stmt = $dbh->prepare("UPDATE rma_detail SET $key = ? WHERE rd_rma_nr = ?"); $update_rma_detail_stmt->bindParam(1, $value); $update_rma_detail_stmt->bindParam(2, $getadmrmaid); $update_rma_detail_stmt->execute(); } } }All i want is when there is an empty (not filled in) input field because it is not mandatory the foreach still continuous to the end. When i use if (!empty($value)){It still outputs these error: Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 1366 Incorrect integer value: ' ' However, when i dont use i got an other error: Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect date value: '' It is however so that the datetime is the very first empty field it come across when looping. I think my if (!empty($value)){ is doing the right thing but still gives error's on integers. Can it be? I allready tried to use trim() or array_filter() but because i previously never used it i dont know if i am doing it the right way so any help is welkom! Thanks! Edited by Raz3rt, 20 May 2014 - 02:56 AM. i am trying to check if the array element (which would be a file) is null or not. when i run it, uploading one file, it says "Please select some files to upload first!" X 3. what am i doing wrong? my code: http://pastebin.com/m0k3fEd2 Hi fellow developers, I'm having a real problem at the moment, I'm trying to capture everything in between <body></body> tags using the following code but it does not print anything: $lines = file("http://www.bbc.co.uk/"); foreach ($lines as $line_num => $line) { $thecontent .= htmlspecialchars($line) . "<br />\n"; } preg_match('/<body.*?>(.*?)<\/body >/', $thecontent, $htmltext); $moretext = $htmltext[1]; echo $moretext; When you do place a "print($thecontent);" into the code the entire html for [whatever the website] does display but I want to capture only the html code in between the body tags. I've tried everything but I just can't get this to work. I would appreciate anyone's help and I'd like to thank you in advance. M Hi all ! What would be the best way to identify and handle an empty array sent from JS to PHP? This rather simple looking problem has resulted in a lot of confusion to me. $_POST['myArray'] = ""; // an empty string -- this is how the empty array from JS is received in PHP
Code: [Select] Array ( [Comment] => Array ( [post_id] => 1 [name] => cc [email] => [body] => spam ) ) How can i check if email is empty or not? Is there any php built in function? Should i use foreach? Hi, I am using an array which allows me to prevent particular subfolders from being included in a script that generates an audio playlist. It looks like this: $disallowed=array('..', '.', 'simon', 'steve'); I would like to find a way of disallowing any folders which are empty, or, perhaps, better still, disallowing folders that do not have any MP3s in them (in case the script interprets folders as not empty if they contain system files which are automatically generated). Would someone be able to help with this? Thanks, Nick In my view file, I instantiate User class and call two methods that have not been declared or initialized in the class: $user = new Models\User(); $user->setFirstName('John'); $user->setLastName('Merlino'); echo $user->getFirstName() . " " . $user->getLastName(); However, I have two private members only available to instances: protected $first_name; protected $last_name; Because I don't want to manually create privileged getters and setters for each of my private members, I use the call method: public function __call($name,$args){ echo $name . "<br />"; echo $args . "<br />"; } Because my methods were not initialized, the interpreter calls the __call method as a last option resort, and passes the name of the method in local variable $name and if exists the arguments passed into the method in local variable $args. Ok so that makes sense. However, when I echo the values of the two variables, I see a blank array created: setFirstName Array setLastName Array getFirstName Array getLastName Array See everytime I call it, there's an array being created. I don't see the purpose of this. Also how often do you use __call() in your php applications, specifically when using MVC? Thanks for response. I'm trying to develop a Joomla plugin for 1.6/1.7 and from what I've read, future versions are supposed to be php E~STRICT compliant. I know that doesn't mean I have to fix this since it is just a notice, but I am curious how one would hide the error. Code: [Select] $task_array = explode('.', JRequest::getVar('task')); # Splits article.save $task = $task_array[1]; #This is line 58 I know it happens because $task_array is empty, but how can i wrap that in something to stop this Notice error? I've tried !empty() but that doesn't work. II am new to jscript and AJAX and have a problem that I need to solve.
I have a form on which I need to input the RGB values of a color that will be used in the next PHP file.
I have choosen a color chooser written in jscript called JS-Color.
There are a number of pre-written scripts for choosing the color, of which I have used the following:
<script type="text/javascript" src="jscolor/jscolor.js"></script> R<input id="red" size="5"> G<input id="grn" size="5"> B<input id="blu" size="5"> - - - H<input id="hue" size="5"> S<input id="sat" size="5"> V<input id="val" size="5"> <p> Choose any color: <input class="color" id="myColor" onchange=" document.getElementById('red').value = this.color.rgb[0]*100 + '%'; document.getElementById('grn').value = this.color.rgb[1]*100 + '%'; document.getElementById('blu').value = this.color.rgb[2]*100 + '%'; document.getElementById('hue').value = this.color.hsv[0]* 60 + '°'; document.getElementById('sat').value = this.color.hsv[1]*100 + '%'; document.getElementById('val').value = this.color.hsv[2]*100 + '%';">I am trying to work out how to use this to get the 3 values that I can post in a form. Looking at the internet, I have found that AJAX is the easiest way to POST from jscript. I have attempted to write some script, but I'm sure I'm way off the mark. Here is my attempt: <!--DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> Design by Free CSS Templates http://www.freecsstemplates.org Released for free under a Creative Commons Attribution 2.5 License Name : Yosemite Description: A two-column, fixed-width design with dark color scheme. Version : 1.0 Released : 20091106 --> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta name="keywords" content="" /> <meta name="description" content="" /> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title></title> <link rel="stylesheet" href="style.css" /> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> </head> <body> <div id="wrapper"><!-- start #wrapper --> <div id="menu"><!-- start #menu --> <ul> <li class="current_page_item"><a href="index.php">Home</a></li> <li><a href="Links.html">Links</a></li> <li><a href="Verse_Menu.html">Verses</a></li> <li><a href="Techniques.html">Techniques</a></li> <li><a href="blog.php">Blog</a></li> <li><a href="Gallery.html">Gallery</a></li> <li><a href="contact.html">Contact</a></li> <li><a href="AboutUs.html">About Us</a></li> <li><a href="Stats_Menu.html">Stats</a></li> </ul> </div><!-- end #menu --> <div id="header"><!-- start #header --> <div id="logo"> <h1><a href="http://www.1066cards4U.co.uk">1066 Cards 4U</a></h1> </div> </div><!-- end #header --> <div id="page"><!-- start #page --> <div id="page-bgtop"><!-- start #page-bgtop --> <div id="page-bgbtm"><!-- start #page-bgbtm --> <div id="content"><!-- start #content --> <h1>Page Title</h1> <script type="text/javscript"> $(function (){ $('#form_id').on('submit', function(e){ e.preventDefault(); $.ajax({ type: "POST", url: "/test_input.php", data: $(this).color.rgb[0]*255, $(this).color.rgb[1]*255, $(this).color.rgb[2]*255, success: function() { alert('success'); } }); }); }); </script> <form method="post" id="form_id"> <script type="text/javascript" src="jscolor/jscolor.js?refresh=adsl"></script> <script type="text/javascript"> jscolor.dir = "jscolor/"; </script> <script type="text/javascript" src="jscolor/jscolor.js"></script> R<input id="red" size="5"> G<input id="grn" size="5"> B<input id="blu" size="5"> H<input id="hue" size="5"> S<input id="sat" size="5"> V<input id="val" size="5"> <p> Choose any color: <input class="color" id="myColor" onchange=" document.getElementById('red').value = this.color.rgb[0]*255; document.getElementById('grn').value = this.color.rgb[1]*255; document.getElementById('blu').value = this.color.rgb[2]*255; document.getElementById('hue').value = this.color.hsv[0]* 60 + '°'; document.getElementById('sat').value = this.color.hsv[1]*100 + '%'; document.getElementById('val').value = this.color.hsv[2]*100 + '%';"> <input type="submit" id="submit" name="submit" value="Send"> </form> <br /><br /><br /><br /> </div><!-- end #content --> <div id="sidebar"><!-- start #sidebar --> <div id="search" ><!-- start #search --> <h2><font color="blue">SITE SEARCH</h2> <script> (function() { var cx = '018330043583532205772:h1v3z6ucuna'; var gcse = document.createElement('script'); gcse.type = 'text/javascript'; gcse.async = true; gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//www.google.com/cse/cse.js?cx=' + cx; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(gcse, s); })(); </script> <gcse:search></gcse:search> </div><!-- end #search --> <div style="clear: both;"> </div><!-- start and end #style --> </div><!-- end #sidebar --> <div style="clear: both;"> </div> </div><!-- end #page-bgbtm --> </div><!-- end #page-bgtop --> </div><!-- end #page --> </div><!-- end #wrapper --> <div id="footer"><!-- start #footer --> <p>Copyright (c) 2008 Sitename.com. All rights reserved. Design by <a href="http://www.freecsstemplates.org/" rel="nofollow">FreeCSSTemplates.org</a>.</p> <p>Copyright (c) 2013 - 1066 Cards 4U - content and design</p> <p><a href="sitemap.html"><font color="blue">Sitemap</font></a></p> </div><!-- end #footer --> </body> </html>Which is the variable that I can use? Is it this.color.rgb[0]*255; for example? I have created a variable $red etc, but it does not even open the test_input.php file. None of the examples I have seen on the internet relate to the task I am trying to figure out. Can anyone advise me? Hi Guys, I'm trying the following.. returning an array from a php function to Ajax success but the alert seems to only display undefined. PHP Code: [Select] public function reply() { $item_id = $this->uri->segment(3); $type = $this->uri->segment(4); if($type == 1){ $data['get_news_item'] = $this->Newsletter_model->get_news_item($item_id); $test = array( "Paul", "Mike"); return $test; } } AJAX Code: [Select] $.ajax({ type: "POST", url: "<?php echo site_url(); ?>newsletter/reply/"+id+"/"+type, cache: false, success: function (data){ alert(data[0]); // So this should display "Paul"? }); [/code] Man, I'm having a rough week with questions--if you're following at home. Basically matching a Coach's first and last name to another table, which if matched will yield information about that coach's team. Code: [Select] // or get user by username $current_user = wp_get_current_user(); $current_first = $current_user->user_firstname; $current_last = $current_user->user_lastname; $current_id = $current_user->ID; echo '<div class="contact_form">'; echo $current_first . ' ' . $current_last .' :: '; $query = "SELECT * FROM schools WHERE coachFirst='".$current_first."' AND coachLast='".$current_last."'"; $result = mysql_query ($query); if(!$result) { echo 'There is not a match for your name.'; } else { while($school= mysql_fetch_array($result)) { echo $school['school'] . ' ' . $school['id']; include(ABSPATH ."wp-content/plugins/my-team/form.php"); } echo '</div>'; echo '<div class="roster">'; include(ABSPATH ."wp-content/plugins/my-team/roster.php"); echo '</div>'; } |