Tuesday, 20 August 2013

Change names of appended table row fields jQuery

Change names of appended table row fields jQuery

I have a table in an html form containing a table that a row is added to
every time a button is clicked. When each row is added, I want the name
and id of each field in the new row (there are four) to be updated from
"Id.0" in the first row to "Id.1" in the second row and then "Id.2" in the
third, etc. I can accomplish this with the id no problem using
var next=$("#QualificationRequirements tr:last").clone();
fixIds(next,nexdex);
nexdex++;
$("#QualificationRequirements").append(next);
function fixIds(element, counter) {
$(element).find("[id]").add(element).each(function() {
this.id = this.id.replace(/\d+$/, "")+counter;
});
}
However I have found that the same logic does not apply to the name
attribute, and
$(element).find("[name]").add(element).each(function() {
this.name = this.name.replace(/\d+$/, "")+counter;
});
causes an error.
Can anyone see what I'm doing wrong? Thanks!

Check invitation accepted with Facebook app

Check invitation accepted with Facebook app

I'm using facebook invite plugin in a facebook app. I want to know if its
possible to know if a user have accepted or refused an invitation request.
I want to track refuse & acception requests for analytics stuff. The best
thing would be that i receive a notification saying yes or no.
I have checked on facebook developers but i dont have find a solution to
my problem :
https://developers.facebook.com/docs/howtos/multi-friend-selector/
If someone could help me, that would be awesome.
Thanks in advance
Regards

How to add dropdown dynamically

How to add dropdown dynamically

I am trying to add the dynamic drop down through javascript.
i have a dropdown which has numbers, when selected creates the drop down.
but i want to add the dynamic dropdown through javascript. how can i do
this?
here is php code
code:
<?php
try {
$dbh = new
PDO('mysql:dbname=theaterdb;host=localhost','tiger','tiger');
} catch (PDOException $e) {
echo 'Connection failed: ' . $e->getMessage();
}
$sql = "SELECT theater_name FROM theater;";
$sth = $dbh->prepare($sql);
$sth->execute();
echo "<select name='theater_name' id='course'
onchange='showUser(this.value);'>";
echo "<option>----Select Theater----</option>";
while($row = $sth->fetch(PDO::FETCH_ASSOC)) {
echo "<option value='" . $row['theater_name'] ."'>" .
$row['theater_name']. "</option>";
}
echo "</select>";
?>
This php code gets the drop down values from mysql database. but this drop
down will be created dynamically from javascript
javascript code
function create(param) {
'use strict';
var i, target = document.getElementById('screens');
target.innerHTML = '';
for(i = 0; i < param; i += 1) {
target.innerHTML +='</br>';
target.innerHTML +='Movie in hall '+i+' ';
target.innerHTML += '<?php
try {
$dbh = new
PDO('mysql:dbname=theaterdb;host=localhost','tiger','tiger');
} catch (PDOException $e) {
echo 'Connection failed: ' . $e->getMessage();
}
$sql = "SELECT theater_name FROM theater;";
$sth = $dbh->prepare($sql);
$sth->execute();
echo "<select name='theater_name' id='course'
onchange='showUser(this.value);'>";
echo "<option>----Select Theater----</option>";
while($row = $sth->fetch(PDO::FETCH_ASSOC)) {
echo "<option value='" . $row['theater_name'] ."'>" .
$row['theater_name']. "</option>";
}
echo "</select>";
?>';
target.innerHTML +=' '+'Timings '+' ';
target.innerHTML += '<input type="text" name="timings">';
target.innerHTML +='</br>';
target.innerHTML +='</br>';
}
}
so now i have added this php code in javascript but it is not creating the
dropdown..
Why? How can i do this

Monday, 19 August 2013

How do you identify and serve gzipped content to Cloudfront in Asp.net mvc?

How do you identify and serve gzipped content to Cloudfront in Asp.net mvc?

I have an asp.net MVC application that serves static content through a
controller method that detects the "Accept-Encoding" header and serves
content accordingly. This was causing problems so I made the compressor
method return Gzipped content regardless of the header values, and I still
get Google PageSpeed telling me that content should be GZipped!
I have seen articles about configuring this in IIS at machine level, but
not how to get this to work when returning compressed content
programmatically.
Can anyone help? Many thanks.

Method Created Objects Deleted on Exit

Method Created Objects Deleted on Exit

Are objects / fields created in a method deleted upon the exit of that
specific method?
Example:
public static void createFolder() {
File folder = new File(C:\example\path "foldername");
folder.mkdir();
}
Would the MEMORY used to store the File "folder" be deleted upon exit of
the "createFolder" method?

Determining A Splitting Field

Determining A Splitting Field

I am trying to determine the splitting fields of a bunch of polynomials.
I'll ask one here and hope that a general enough technique can be
described to find the rest of them.
Currently, I'm trying to find the splitting field of
$(x^{15}-5)(x^{77}-1)$ over $\Bbb Q$, find the degree, and determine if
it's a Galois extension.
Now, I know that the right polynomial is the cyclotomic polynomial, hence
has degree $\varphi(77)=60$, over $\Bbb Q$. The left polynomial is
irreducible by Eisenstein's Criterion, hence adjoining $\sqrt[15]{5}$
gives a degree 15 extension and as a separate extension, adjoining
$\zeta_{15}$ (a primitive $15^{th}$ root of unity) gives a degree $8$
extension. All of this seems well and good, but now I'm lost. The
splitting field itself is obvious, but how can I check the degree and
determine if it is Galois?

javascript loop array get counts

javascript loop array get counts

If I have an array like this how can I loop through and push the counts
into a a new array?
All help wlcomed!
var Products = [
['Product A'],
['Product A'],
['Product A'],
['Product A'],
['Product A'],
['Product B'],
['Product B'],
['Product B'],
['Product B'],
['Product B'],
['Product B'],
['Product B'],
['Product B'],
['Product B'],
['Old Product B'],
['Old Product B'],
['Old Product B'],
['Old Product B'],
['Old Product B'],
['Old Product]
];
End Goal :
var UniqueProducts = [
['Product A',5],
['Product B',6],
['Old Product B',9]
];