我有一个被循环吐出的表单,它的目的是以可管理的方式显示车辆库存,所以你可以编辑它的任何内容我的问题是当我点击隐藏/显示它提交表单时,因为是清空它会将我重定向到主页
它曾经工作过。当我允许我的代码从谷歌获取 jquery 时,它实际上可以工作,我确定这不是根本问题,但它似乎可以解决它
这是我的表格代码
<?php
function manage_vehicles($soldvalue)
{
$actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
echo '<div class="span12">
<a href=""><button id="deleteall" name="deleteall" class="btn btn-danger" type="submit" >Delete</button></a> ';
if ($actual_link == 'http://localhost/cardealerwins/admin.php?manage_vehicles')
{
echo '<a href="admin.php?manage_sold"><button href="admin.php?manage_sold" id="managesold" name="deleteall"
class="btn btn-success" type="submit" >Manage sold vehicles</button></a>';
}
else if ($actual_link == 'http://localhost/cardealerwins/admin.php?manage_sold')
{
echo '<a href="admin.php?manage_vehicles"><button href="admin.php?manage_vehicles" id="managesold" name="deleteall"
class="btn" type="submit" >Manage active vehicles</button></a>';
}
echo '</div>';
//get the total number of vehicles active in the database to loop through them and displaying them to manage
$query = mysql_query("SELECT COUNT('auto_id') FROM `auto` WHERE `sold` = $soldvalue");
$all = mysql_result($query, 0); //store the value so we can run this loop accordingly
$counter = 1;
$auto_id = 0; //auto id equal to zero as starting point, it will increase randomly to as many vehicles it will diplay
while ($counter <= $all) //ie run for every car
{
$fields = 'auto_id, year, make, model, engine, sound_system,mileage, price, vin, att1, att2, att3, att4, att5, att6, att7, att8,
att9, att10, att11, att12, att13, att14, att15, picture1, picture2, picture3, picture4, picture5, picture6, picture7, picture8,
picture9, picture10, picture11, picture12';
//check where the auto id is greater then the previously one according to $auto_id which increments
$data = mysql_fetch_assoc(mysql_query("SELECT $fields FROM `auto` WHERE `auto_id` > $auto_id AND `sold` = $soldvalue"));
$auto_id = $data['auto_id']; //here is the magic, we set the auto id to the current one being spitted out so it follows through
//now with all the $data retrieved from the database we can print car by car with its unique info and ids
echo '<div id="displaycarwrap" class="span3 container">
<input type="checkbox" value="'. $data['auto_id'] .'" class="deletebox" /><br />
<a href="#"><img src="' . $data['picture1'] . '"></a>
<form action="admin/tool/editvehicle.php" method="post">
<ul>
<li>
<br><b>Price</b>: <input name="price" type="text" class="span2" value="' . $data['price'] . '">
</li>
<li>
<button name="delete" class="btn btn-danger" type="submit" >Delete Vehicle</button>
</li>
<li>
<button name="sold" class="btn btn-success" type="submit" >Mark as Sold</button>
</li>
<li>
<button class="btn btn-primary" name="editpictures" type="submit" >Edit Pictures</button>
</li>
<li>
<button type="submit" name="editauto" class="btn btn-inverse" >Apply Changes</button>
</li>
</ul>
<button class="show_hide btn btn-mini icon-th-list" href="#" rel="slidingDiv'. $counter .'">View details</button>
<div id="slidingDiv'. $counter .'" class="toggleDiv" style="display: none;">
<ul> <br />
<li><b>Year</b>:<br /><input type="text" name="year" value="' . $data['year'] . '" class="span2"></li>
<li><b>Make</b>: <br /><input type="text" name="make" value="' . $data['make'] . '" class="span2"></li>
<li><b>Model</b>: <br /><input type="text" name="model" value="' . $data['model'] . '" class="span2"></li>
<li><b>Mileage</b>: <br /><input type="text" name="mileage" value="' . $data['mileage'] . '" class="span2"></li>
<li><b>Engine</b>:<br /> <input type="text" name="engine" value="' . $data['engine'] . '" class="span2"></li>
<li><b>Stereo</b> <br /><input type="text" name="sound_system" value="' . $data['sound_system'] . '" class="span2"></li>
<li><b>Attribute 1 </b> <input type="text" name="att1" value="' . $data['att1'] . '" class="span2"></li>
<li><b>Attribute 2</b> <input type="text" name="att2" value="' . $data['att2'] . '" class="span2"></li>
<li><b>Attribute 3</b> <input type="text" name="att3" value="' . $data['att3'] . '" class="span2"></li>
<li><b>Attribute 4</b> <input type="text" name="att4" value="' . $data['att4'] . '" class="span2"></li>
<li><b>Attribute 5</b> <input type="text" name="att5" "value="' . $data['att5'] . '" class="span2"></li>
<li><b>Attribute 6</b> <input type="text" name="att6" value="' . $data['att6'] . '" class="span2"></li>
<li><b>Attribute 7</b> <input type="text" name="att7" value="' . $data['att7'] . '" class="span2"></li>
<li><b>Attribute 8</b> <input type="text" name="att8" value="' . $data['att8'] . '" class="span2"></li>
<li><b>Attribute 9</b> <input type="text" name="att9" value="' . $data['att9'] . '" class="span2"></li>
<li><b>Attribute 10</b> <input type="text" name="att10" value="' . $data['att10'] . '" class="span2"></li>
<li><b>Attribute 11</b> <input type="text" name="att11" value="' . $data['att11'] . '" class="span2"></li>
<li><b>Attribute 12</b> <input type="text" name="att12" value="' . $data['att12'] . '" class="span2"></li>
<li><b>Attribute 13</b> <input type="text" name="att13" value="' . $data['att13'] . '" class="span2"></li>
<li><b>Attribute 14</b> <input type="text" name="att14" value="' . $data['att14'] . '" class="span2"></li>
<li><b>Attribute 15</b> <input type="text" name="att15" value="' . $data['att15'] . '" class="span2"></li>
<li><b>Vin</b> <input type="text" name="vin" value="' . $data['vin'] . '" class="span2"></li>
<li><input type="text" name="auto_id" value="' . $data['auto_id'] . '" class="span2" readonly><li>
<ul>
</div>
</form>
</div>';
$counter++; //used for the while loop it self and for classes id uniqueness for javascript
}
}
?>
这是我的 jquery 的代码:
//function to hide the extra info for the cars in manage vehicles
(function ($) {
$.fn.showHide = function (options) {
//default vars for the plugin
var defaults = {
speed: 250,
easing: '',
changeText: 0,
showText: 'View details',
hideText: 'close'
};
var options = $.extend(defaults, options);
$(this).click(function () {
// optionally add the class .toggleDiv to each div you want to automatically close
$('.toggleDiv:hidden').slideUp(options.speed, options.easing);
// this var stores which button you've clicked
var toggleClick = $(this);
// this reads the rel attribute of the button to determine which div id to toggle
var toggleDiv = $(this).attr('rel');
// here we toggle show/hide the correct div at the right speed and using which easing effect
$(toggleDiv).slideToggle(options.speed, options.easing, function() {
// this only fires once the animation is completed
if(options.changeText==1){
$(toggleDiv).is(":visible") ? toggleClick.text(options.hideText) : toggleClick.text(options.showText);
}
});
return false;
});
};
})(jQuery);
$(document).ready(function(){
$('.show_hide').showHide({
speed: 250, // speed you want the toggle to happen
easing: '', // the animation effect you want. Remove this line if you dont want an effect and if you haven't included jQuery UI
changeText: 1, // if you dont want the button text to change, set this to 0
showText: 'View details',// the button text to show when a div is closed
hideText: 'Close' // the button text to show when a div is open
});
});
我的控制台告诉我:
Uncaught ReferenceError: google is not defined
我认为与它无关
未捕获的 referenceError 的错误
Uncaught ReferenceError: google is not defined
jQuery.fn.extend.addEventListener
jQuery.fn.(anonymous function)
$.fn.showHide managevehicles.js:20
(anonymous function) managevehicles.js:46
fire jquery2.js:3074
self.fireWith jquery2.js:3186
jQuery.extend.ready jquery2.js:433
completed jquery2.js:104
Uncaught ReferenceError: google is not defined
jQuery.fn.extend.addEventListener
jQuery.fn.(anonymous function)
(anonymous function) scripts.js:10
jQuery.event.dispatch jquery2.js:5116
elemData.handle jquery2.js:4787