I'm trying to be able to dynamically expand / collapse multiple divs with the same code....
it's controlled with the click of a span (toggle) and then i'm trying to get the next id(the div that would slide up and down)
$('span').toggle(
function() {
$('#albumholder').slideToggle(600);
$(this).html('-');},
function() {
$('#albumholder').slideToggle(600);
$(this).html('+');}
);
This code works to expand 1 div... but assume i have a divs #downloadholder#linksholderetc...
How can i achieve the same effect with the same code? Thanks!
Just trying out Hibernate (with Annotations) and I'm having problems with my mappings. I have two entity classes, AudioCD and Artist.
@Entity
public class AudioCD implements CatalogItem {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
private String title;
@ManyToOne(cascade = { CascadeType.ALL }, optional = false)
private Artist artist;
....
}
@Entity
@Table(uniqueConstraints = { @UniqueConstraint(columnNames = { "name" }) })
public class Artist {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
@Column(nullable = false)
private String name;
.....
}
I get AudioCD objects from an external source. When I try to persist the AudioCD the Artist gets persisted as well, just like I want to happen. If I try persisting another different CD, but Artist already exists I get errors due to constraint violations.
I want Hibernate to recognise that the Artist already exists and shouldn't be inserted again. Can this be done via annotations? Or do I have to manage the persistence of the AudioCD and Artist seperately?
I got this SQL:
UPDATE users2
SET picture = 'sites/site2/files/pictures/' + picture;
WHERE picture NOT IS NULL
And the only thing I get are that all picture fields get the value '0'.
Hello there,
I am currently having the above issue, where on a CMS called phpVMS a CSS displaying front page works fine on the first account, but does not on any other user accounts. This only applies to the frontpage, and all of the tags seem to be closed. The top half of the picture is how it should display and how it displays for user GSM1001. The bottom half is for users GSM1002 upwards. I am really puzzled and I'd appreciate any suggestions. I am happy to post snippets of the code here or on jsFiddle if you require to see it.
Thank you, kind regards.
I have a class
public Student student {get;set;}
public Students students {get;set;}
both class properties are same..
I am getting student values from data base.. I need to assign those values to students..
can anybody tell me how to do this?
Hi,
I'm trying to count several joined tables but without any luck, what I get is the same numbers for every column (tUsers,tLists,tItems). My query is:
select COUNT(users.*) as tUsers,
COUNT(lists.*) as tLists,
COUNT(items.*) as tItems,
companyName
from users as c
join lists as l
on c.userID = l.userID
join items as i
on c.userID = i.userID
group by companyID
The result I want to get is
---------------------------------------------
# | CompanyName | tUsers | tlists | tItems
1 | RealCoName | 5 | 2 | 15
---------------------------------------------
what modifications do i have to do to my query to get those results?
Cheers
i am using two table postjob and job location
want to distinct jobtitle
The query is:
select postjob.jobtitle,
postjob.industry,
postjob.companyname,
postjob.jobdescription,
postjob.postid,
postjob.PostingDate,
Job_Location.Location,
Job_Location.PostigID
from postjob
inner join Job_Location
on postjob.postid = Job_Location.PostigID
Where postjob.industry=' Marketing, Advertising'
output of this query
http://www.justlocaldial.com/Industry_search.aspx?ind=Marketing,%20Advertising
This line:
used_emails = [row.email for row
in db.execute(select([halo4.c.email], halo4.c.email!=''))]
Returns:
['[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]']
I use this to find a match:
if recipient in used_emails:
If it finds a match I need to pull another field (halo4.c.code) from the database in the same row. Any suggestions on how to do this?
I know I am going about this in an unusual way, every tut I've seen uses multiple tables, but due to the way the rest of my site works I would like to create a chained select which operates using a single table.
My table structure is:
----------------------
|Catagory|SubCategory|
|01|cat1 |subcat1 |
|02|cat1 |subcat2 |
|03|cat2 |subcat1 |
|04|cat2 |subcat2 |
----------------------
The code I have so far looks like:
<tr>
<td class="shadow"><strong>Category:</strong> </td>
<td class="shadow">
<select id="category" name="category" style="width:150px">
<option selected="selected" value="<?php echo $category ?>"><?php echo $category?></option>
<?php
include('connect.php');
$result1 = mysql_query("SELECT DISTINCT category FROM categories")
or die(mysql_error());
while($row = mysql_fetch_array( $result1 )) {
$category = $row['category'];
echo "<option value='". $row['category'] ."'>". $row['category'] ."</option>";
}
?>
</select>
</td>
</tr>
<tr>
<td class="shadow"><strong>Sub Category:</strong> </td>
<td class="shadow">
<select id="sub_catgory" name="sub_category" style="width:150px;">
<option selected="selected" value="<?php echo $sub_category ?>"><?php echo $sub_category ?></option>
<?php
include('connect.php');
$result2 = mysql_query("SELECT sub_category FROM categories WHERE ")
or die(mysql_error());
while($row = mysql_fetch_array ($result2 )){
echo "<option value='" . $row['sub_category'] . "'>". $row['sub_category']. "</option>";
}
?>
</select>
</td>
</tr>
On the second select I am not sure how to state the WHERE clause. I need it to display the subcategories which have the same category as selected in the first select.
PART 2 how would I include AJAX in this to preload the data so i don't need to refresh the page.
Could someone either help me finish what I've started here or point me to a good tutorial.
thanks
I want to do something like this:
foreach (Customer c in customers)
{
yield return c.Name;
yield return "0";
}
I started:
customers.Select(c => new
{
c.Name,
Second = "0"
}).???
But then what?
I've got a list of links that point to images, and a js function that takes a URL (of an image) and puts that image on the page when the function is called.
I was originally adding an inline onlick="showPic(this.getAttribute('href'))" to each a, but I want to separate out the inline js. Here's my func for adding an onclick to each a tag when the page loads:
function prepareLinks(){
var links = document.getElementsByTagName('a');
for(var i=0; i<links.length; i++){
var thisLink = links[i];
var source = thisLink.getAttribute('href');
if(thisLink.getAttribute('class') == 'imgLink'){
thisLink.onclick = function(){
showPic(source);
return false;
}
}
}
}
function showPic(source){
var placeholder = document.getElementById('placeholder');
placeholder.setAttribute('src',source);
}
window.onload = prepareLinks();
...but every time showPic is called, the source var is the href of the last image. How can I make each link have the correct onclick?
I have a class with a private vector of doubles.
To access or modify these values, at first I used methods such as
void classA::pushVector(double i)
{
this->vector.push_back(i);
}
double classA::getVector(int i)
{
return vector[i];
}
This worked for a while until I found I would have to overload a lot of operators for what I needed, so I tried to change it to get and set the vector directly instead of the values, i.e.
void classA::setVector(vector<double> vector)
{
this->vector = vector;
}
vector<double> classA::getVector()
{
return vector;
}
Now, say there is a classB, which has a private classA element, which also has get and set methods to read and write. The problem was when I tried to push back a value to the end vector in classA.
void classB::setFirstValue(double first)
{
this->getClassA().getVector().push_back(first);
}
This does absolutely nothing to the vector. It remains unchanged and I can't figure out why... Any ideas?
I have two servers, server1 and server2 on same network but require username and password to be mapped. server1 has a text file as C:\Users\output.txt.
I want to create and schedule a batch script on server1, which should copy and replace output.txt file from server1 to server2 at path E:\data\output.txt on daily basis.
I don't want to map server2 manually every time I start my computer nor do I want to enter my username and password each time.
I am using following commands in a batch, but not working;
net use C: \\server2\E:\data server2password /user:server2domain\server2username /savecred /p:yes
xcopy C:\Users\output.txt E:\data\
Hi,
as in the title, i have:
[ServiceContract]
public interface IService
{
[OperationContract]
[WebGet(UriTemplate="abc")]
Stream GetResponse(Stream in);
}
public class Service : IService
{
public Stream GetResponse(Stream in)
{
some_function()
}
}
is it possible to pass a request context to some other function that will respond to the request?
The menu I want to show to the users changes depending on their rights
After user authentication I redirect to my menu action which calls its view
access/menu.html.erb
<% if admin? %>
<%form_for(:user, :url => {:controller => 'admin_users',:name => session[:username]}) do |admin|%>
<ul><h2>Administrator: <%=session[:username]%></h2></ul>
<%= render(:partial =>'admin_form',:locals => {:admin => admin})%>
<%end%>
<%else%>
<%form_for(:user, :url => {:controller => 'students',:name => session[:username]}) do |student|%>
<ul><h2>???????: <%=session[:surname].to_s + " " + session[:name].to_s%></h2></ul>
<%= render(:partial =>'student_form',:locals => {:student => student})%>
<%end%>
<%end%>
And the forms look:
_student_form:
<table>
<ul>
<li><%=link_to '?????',{:controller => 'students'}%></li>
</ul>
<ul>
<li><%=link_to '?????? ?????????',{:controller => 'students'}%></li>
</ul>
<ul>
<li><%=link_to '???????? ?????? ????',{:controller => 'students'}%></li>
</ul>
<ul>
<li><%=link_to '???????? ??????',{:controller => 'students'}%></li>
</ul>
<ul>
<td> </td>
</ul>
</table>
_admin_form:
<table>
<ul>
<li><%=link_to '?????????? ????????????????',{:controller => 'AdminUsers',:role_id => 1}%></li>
</ul>
<ul>
<li><%=link_to '?????????? ????????',{:controller => 'AdminUsers',:role_id => 2}%></li>
</ul>
<ul>
<li><%=link_to '?????????? ??????????',{:controller => 'AdminUsers',:role_id => 3}%></li>
</ul>
<ul>
<li><%=link_to '?????????? ???????????',:controller => 'subjects'%></li>
</ul>
<ul>
<td> </td>
</ul>
</table>
If a log in as a student I get:
But if I log in as an administrator I get
How can this be posible??
I am doing a couple of joins with a variable in the WHERE clause. I'm not sure if I am doing everything as efficiently as I could, or even using the best practices but my issue is that half my tables have data for when tableC.type=500, and the other half don't resulting in the entire query failing.
SELECT tableA.value1 , tableB.value2, tableC.value3 FROM tableA
JOIN tableB ON tableB.id=tableA.id
JOIN tableC ON tableC.id=tableB.id
WHERE tableA.category=$var && tableC.type=500;
What I would like to happen is to still get tableA.value1 and tableB.value2 even if there is no field in tableC with a type=500.
any thoughts? i'm totally stumped as how to approach this...
I follow this rule but some of my colleagues disagree with it and argue that if a class is smaller it can be left in the same file with other class(es).
Another argument I hear all the time is "Even Microsoft don't do this, so why should we?"
What's the general consensus on this? Are there cases where this should be avoided?
(Sorry I know this is an old chestnut; I have found similar answers here but not an exact answer)
These are frequent hand written queries from a console so I is what I am looking for is the easiest thing to type
SELECT * FROM tbl_loyalty_card WHERE CUSTOMER_ID REGEXP "[0-9A-Z]";
or
SELECT * FROM tbl_loyalty_card WHERE LENGTH(CUSTOMER_ID) >0; -- could match spaces
Do you have anything quicker to type even if it's QAD?
I would like to write an activity that after clicking on a button turns off the screen and then turns it back on after 2 secs.
I tried using the following code in order to power off the screen:
WindowManager.LayoutParams lp = getWindow().getAttributes();
lp.screenBrightness = 0/(float)255;
getWindow().setAttributes(lp);
But it would only take effect when then onClick function returns. I tried running it into a handler but with no success.
I need to find a way to force the setting to get applied before the function returns so that I can call the power on function 2 secs later on the same onClick call.
I also found it very hard to wakeup the device afterwards.
While this code works if I power off the screen using the physical button it doesn't seem to work when the phone is powered off using the technique described previously.
PowerManager pm = (PowerManager)this.getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK|PowerManager.ACQUIRE_CAUSES_WAKEUP |
PowerManager.ON_AFTER_RELEASE ,"Dev Tag");
try
{
wl.acquire();
wl.release();
}
catch (Exception e)
{
Toast.makeText(this, e.getMessage(),20).show();
}
Thanks you in advance for your help!
So this is interesting, and apparently beyond my SQL skillset.
I need to select a particular record where an ID="0003" (or whatever) from either table1 or table2 if table1 doesn't have that record. Then I need to join table1 and table2 on a mutual field they both have (field name is Product_ID)
I was playing with all sorts of variations of the following, (no, it doesn't work) but after 2 days of groping through the internet and a big SQL book I still can't figure anything out.
SELECT ProductStock.Product_ID AS PSID,
Products.ID AS PID,
ProductStock.*,
Products.*
FROM ProductStock, Products LEFT JOIN (Products AS Pr) ON Pr.ID=ProductStock.Product_ID WHERE (ProductStock.ID="6003" OR Products.ID="6003")
Hey guys. I don't know much JS, but I wanted to do some quick work with jQuery.
But I've been staring at this for about an hour and I don't understand what I missed:
<script type="text/javascript">
$('#qty_6035').change(function () {
var substractedQty, stockQty, remQty;
substractedQty = (int) $('#qty_6035').val(); // missing ; before statement
stockQty = (int) $('#orig_qty_6035').val();
$('#rem_qty_6035').html(stockQty-substractedQty);
});
</script>
jQuery library is included at the beggining of the document.
Thanks.
Hi!
Is is possible to do a post from an Action "Save" in a controller "Product" to an Action "SaveAll" in a controller "Category"??
And also passing a FormCollection as parameter
Thanks!!