can someone rephrase this below sentence so that the user can easily understand the below line
" Please turn off the pop up blocker by going to tools option pop up blocker turn off pop up blocker in the browser and try again"
I am working on Ruby on Rails application, with Prototype.
I want to display a loading div automatically with every ajax request and hide it on completion, without writing code for every ajax request in my application.
Is there anyway to do this.
<div id="loader">Loading...</div>
I'm trying to complete some homework and it appears the book might have gotten it wrong. I have a simple html page that allows user to pick a credit card in our case american express. The user then enters a number and evalutes that number based on a regular expression. My question ends up being when test() evaluates the number it returns a boolean or a string? I should then compare that string or boolean? True == true should fire off the code in a nested if statement. Heres what the book gives me as valid code:
if(document.forms[0].cardName.value == "American Express")
{
var cardProtocol = new RegExp("^3[47][0-9]{13}$"); //REGEX ENTRY HERE
if(cardProtocol.test(document.forms[0].cardNumber.value))
document.forms[0].ccResult.value = "Valid credit card number";
}
The above code doesn't work in firefox. I've tried modifying it with 2 alerts to make sure the number is good and the boolean is good...and still no luck:
if(document.forms[0].cardName.value == "American Express")
{
var cardProtocol = new RegExp("^3[47][0-9]{13}$"); //REGEX ENTRY HERE <------
alert(document.forms[0].cardNumber.value)
alert(cardProtocol.test(document.forms[0].cardNumber.value))
if((cardProtocol.test(document.forms[0].cardNumber.value)) == true ) // <--Problem
{
document.forms[0].ccResult.value = "Valid credit card number";
}
else
{
document.forms[0].ccResult.value = "Invalid credit card number";
}
}
Any ideas? the if loop is the culprit but I'm not figuring out why it is not working. Please throw up the code for the if loop! Thanks for the help!
hi all,
I'm using jQuery to parse some XML, like so:
function enumOptions(xml) {
$(xml).find("animal").each(function(){
alert($(this).text());
});
}
enumOptions("<root><animal>cow</animal><animal>squirrel</animal></root>");
This works great. However if I try and look for nodes called "option" then it doesn't work:
function enumOptions(xml) {
$(xml).find("option").each(function(){
alert($(this).text());
});
}
enumOptions("<root><option>cow</option><option>squirrel</option></root>");
There's no error, just nothing gets alerted, as if the find isn't finding anything. It only does it for nodes called option everything else I tested works ok!
I'm using the current version of jQuery - 1.4.2.
Anyone any idea?
TIA.
bg
Hello,
I am trying to get the Treemap plugin (http://www.jquery.info/spip.php?article40) working with jQuery v1.3.x. The plugin works with jQuery v1.1 and v1.2 but for some reason it fails with the v1.3 base.
This is the browser error "Error: uncaught exception: Syntax error, unrecognized expression: "
Does anyone know changes occurred between JQuery v1.2 and v1.3 that could cause this?
Cheers,
D
Hi,
I am creating this content slider, you can view/edit here:
http://jsbin.com/esame4
I have put in place setInterval so that animation runs automatically, however, when it is run for the first time, google image is shown but not afterwords. Should be simple but i am unable to figure out the problem.
function doIt(param) {
var localVar = param;
//do lots of stuff with localVar
}
function doIt(param) {
//do lots of stuff with param
}
Is there any difference in terms of efficiency between the code above?
I want to create a function to simplify configuration of jQuery UI AutoComplete. Here is my function code:
(function($) {
$.fn.myAutocomplete = function() {
var cache = {};
var dataUrl = args.dataUrl;
var dataSend = args.dataItem;
$.autocomplete({
source: function(request, response) {
if (cache.term == request.term && cache.content) {
response(cache.content);
}
if (new RegExp(cache.term).test(request.term) && cache.content && cache.content.length < 13) {
var matcher = new RegExp($.ui.autocomplete.escapeRegex(request.term), "i");
response($.grep(cache.content, function(value) {
return matcher.test(value.value)
}));
}
$.ajax({
url: dataUrl,
dataType: "json",
type: "POST",
data: dataSend,
success: function(data) {
cache.term = request.term;
cache.content = data;
response(data);
}
});
},
minLength: 2,
});
}
}) (jQuery);
but when I'm using this function like:
$("input#tag").myAutocomplete({
dataUrl: "/auto_complete/tag",
dataSend: { term: request.term, category: $("input#category").val() }
});
It's give me an error:
Uncaught ReferenceError: request is not defined
I need to populate the first box with the items from a db table. Users would choose from the first box, and either drag value(items) to the second for selection, or would select items, and then click a button to move them over to the 2nd box. After that I need to update the db with the selected values/items.
I am grabbing data through a jQuery Ajax call, and displaying it on the page. I need to wait for both the DOM to load and for the Ajax call to complete before I can use the data to display it on the page. Can an Ajax call ever complete before the DOM has loaded? I'm just trying to determine where I need to put my method that will manipulate the DOM and use the data I'm getting back.
http://jsfiddle.net/5DB6K/
I have this game being made where you shoot enemies from the sides of the screen. I've got the bullets moving and being removed when they reach the end of the screen (if they didn't hit any enemy) and removing the enemy when they collide with it.
//------------collision----------------//
if(shot === true){
bulletY = $('.bullet').position().top + 2;
bulletX = $('.bullet').position().left + 2;
$('.enemy').each(function(){
if($('.enemy').hasClass('smallEnemy')){
enemyY = $(this).position().top + 7;
enemyX = $(this).position().left + 7;
if(Math.abs(bulletY - enemyY) <= 9 && Math.abs(bulletX - enemyX) <=9){
$(this).remove();
score = score + 40;
bulletDestroy();
}
}
});
}
However, the bullet destroys every enemy if the collision check is right which isn't what I want. I want to check if the enemy has the class of either smallEnemy, medEnemy, or lrgEnemy and then do the collision check which is what I thought I had but it doesn't seem to work.
Also, the game starts to lag the more and more time goes on. Would anyone know the reason for that?
I have a code and the way it should work is,when they click on NEW CUSTOMER,it takes them to test1.php where in they enter the details and they hit submit.it saves all the details in properly in the database and when i go back and hit REFRESH ,it should come up with the customer details which they had entered in previously.
But what happens is, when i click on the REFRESH,it refreshes the same old page which is empty.I wanted to find out where am i missing the logic.Thanks in advance.
The sample code would be
<tr>
<td class="tdvisitbig" colspan="5">THIS IS A TEST</td>
</tr>
<tr>
<td class='tdvisitbig' colspan="5"><input type="button" onClick="openVisit('test1.php?id=<?=$key?>&name=<?=$name?>');return false;" value="NEW CUSTOMER" class="submit"> <input type="button" value="REFRESH" name="add_xyz" class="submit" onClick="document.add.target='_self';document.add.action='test3.php?redirect=visit§ion=test page';document.add.submit();"></td>
</tr>
<?
$q = "SELECT address,customernum,status FROM customer WHERE name='$name' ORDER BY customernum";
$r = mysql_query( $q , $Link );
while( $rw = mysql_fetch_assoc( $r ) )
{
extract( $rw );
?>
<tr>
<? } ?>
I put some jquery in my website that makes the text move to the right when the page changes. It works in Firefox and Safari but it doesn't work in Internet Explorer. My url to my website: http://katieduck.com/Courses/Improvisation%20Winter%20Course%20Dartington.html
Here is the code that is not working:
$(document).ready(function() {
$('#tabvanilla > ul').tabs({ fx: { height: 'toggle', opacity: 'toggle' } });
$('#featuredvid > ul').tabs();
});
Maybe you can find out what is wrong.
Not sure if this is against stackoverflow rules as it's not a specific code question but I really need a little help.
I want to know if it is possible to create a search feature (search box) on an HTML webpage that will query a database and return the results?
Basically I have a database of products and their related categories. A user would come to the website, enter the category in the search field...somehow query the database and return the results on a new page.
Note: the results page doesn't have to be HTML (could be PHP etc).
If you could also include a little guidance on how (please nothing detailed, just need a direction).
Thank you!
I have created a html page in php and upon submission i validates that page using PHP. After validating i want to show an alert msg to show its status like showing any greeting or request for re-enter.
I have dont validation. Now i m using
header( 'Location: http://localhost/assignment/WebForm.htm' ) ;
to redirect user to same page but with a alert msg at page load or something like that. What I need to do ?
{"paging": {"pageNum":2,"action":"Next","type":"","availableCacheName":"getAllFunds","selectedCacheName":"","showFrom":101,"showTo":200,"totalRec":289,"pageSize":100},
"Data":[{"sourceCodeId":0,"radio_fund":"individua
l","availableFunds":[],"fundId":288,"searchName":[],"fundName":"Asian Equity Fund A Class Income","srcFundGrpId":"PGI","firstElement":0,"las
tElement":0,"totalElements":0,"pageList":[],"standardExtract":true}]
I have json file with above format with two fileds,one paging and one is Data array.
I able to retrieve values of paging,but i am not able to retrieve the values of data array with .each function of jquery.
Any suggestions or inputs really appreciated.
$('<a />').attr({
'href': '#'
})
.append(
$('<img />').attr({
'id' : 'img',
'src' : 'edit.png'
}))
.appendTo('body');
Is the the "right way" to go about adding <a href="#"><img src="edit.png" id="img" /></a> to the body?
Also how would I add some css onto the img?
i need to run this sql query , which give me a list of Id and Dates
i want to click each result and take with me the Id value to the next form
i wrote this query above but i see in the debager that the hidden ID get his value but not pass to the next form
i think i have a problem with the submit() .
where should i put him ?
thanks anat
function ShowAllCarts($user_email) {
$connB = new ProductDAO();
$connB->Connect();
$pro_query = "SELECT * FROM Cart WHERE `Email`='$user_email';";
$db_result = $connB->ExecSQL($pro_query);
$html_result = '<div data-role="content"> <ul data-role="listview" data-theme="b"> ';
$html_result .= '<form action="PreviouscartProduct.php" method="POST"/>';
while($row_array = $db_result->fetch_array(MYSQLI_ASSOC))
{
$Id= $row_array['Id'];
$Date= $row_array['Date'];
//$html_result //
$html_result .="<li><a href='PreviouscartProduct.php'>Cart number: $Id from Date: $Date><input type='hidden' name='Id' value'<?=$Id?>'</input></a></li>'";
$html_result .= '<a onclick="this.form.submit();" </a>;
}
$html_result .= ' </ul> </div>';
$html_result .= '</form>';
$connB->Disconnect();
return $html_result;
}
//display all carts
$func_result = ShowAllCarts($Email);
I'm trying to prevent certain keys from being entered into an input box, but only if that particular key is pressed whilst the shift key is held:
$('selector').keydown(function(e) {
console.log(e.shiftKey);
if (e.shiftKey && e.which == 51) {
e.preventDefault();
alert('Disallowed');
}
});
The alert fires but the character still appears in the text box. If I remove e.shiftKey from the if statement and press the key (without shift held), the alert fires and the character does not appear in the text box.
I've tried searching around for an explanation as to why this happens but to no avail, any help would be greatly appreciated!
edit
Removing the alert seems to fix the problem (which seems bizarre), I'd really love to know why it behaves in this way though, it doesn't seem to make any sense.
Thanks
How to add "Back to top" link at bottom at is browser window is shorter than page, using jquery?
<div id="mainContent">
<p>Some content</p>
</div>
If some content is bigger than browser window ( I mean if vertical bar comes on the page)
then i want to add Back to top just before closing the div.
<div id="mainContent">
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
<a href="#"> Back to top </a>
</div>