Cakephp get data from another model
I'm developing an e-commerce website. I have 2 tables - Customers & Shipping
Field in Customers - id, name, address, city, postal & country Field in
Shipping - id, address, city, postal & country
The process flow, after the customer click checkout button, they need to
fill up shipping form (shipping - add.ctp).
But in add.ctp, i also want to show address from table customer. So, I can
put check button - Use this address as shipping address.
Anyone can help how the controller & add.ctp looks like? Thank You.
Thursday, 3 October 2013
Wednesday, 2 October 2013
Find maximum value of a continuous function at a specific resolution
Find maximum value of a continuous function at a specific resolution
Imagine having a function that is continuous over a range [0.0,n]. Are
there any algorithms to find the maximum value of the function given a
minimum step size s more quickly than simple iteration? The simple
iteration is straightforward to program but the time complexity grows when
n / s is large.
double maxValue = 0;
double maxValueX = 0;
double s = 0.1 * n;
for (double x = 0.0; x <= n; x += s)
{
double value = someFunction(x);
if(value > maxValue) {
maxValue = value;
maxValueX = x;
}
}
I have tried this approach which is much quicker, but don't know if it
will get stuck on local maximums.
double min = 0;
double max = n;
int steps = 10;
increment = (max - min) / steps;
while (increment > s)
{
double maxValue = 0;
double maxValueX = X;
for (double x= min; x <= max; x+= increment)
{
double value = someFunction(x);
if(value > maxValue) {
maxValue = value;
maxValueX = x;
}
}
min = Math.Max(maxValueX - increment, 0.0);
max = Math.Min(maxValueX + increment, n);
increment = (max - min) / steps;
}
Imagine having a function that is continuous over a range [0.0,n]. Are
there any algorithms to find the maximum value of the function given a
minimum step size s more quickly than simple iteration? The simple
iteration is straightforward to program but the time complexity grows when
n / s is large.
double maxValue = 0;
double maxValueX = 0;
double s = 0.1 * n;
for (double x = 0.0; x <= n; x += s)
{
double value = someFunction(x);
if(value > maxValue) {
maxValue = value;
maxValueX = x;
}
}
I have tried this approach which is much quicker, but don't know if it
will get stuck on local maximums.
double min = 0;
double max = n;
int steps = 10;
increment = (max - min) / steps;
while (increment > s)
{
double maxValue = 0;
double maxValueX = X;
for (double x= min; x <= max; x+= increment)
{
double value = someFunction(x);
if(value > maxValue) {
maxValue = value;
maxValueX = x;
}
}
min = Math.Max(maxValueX - increment, 0.0);
max = Math.Min(maxValueX + increment, n);
increment = (max - min) / steps;
}
How to identify unbound variables for auto-including of modules using Template Haskell?
How to identify unbound variables for auto-including of modules using
Template Haskell?
Is it possible to use Template Haskell to pre-analyze a code, searching
for undefined symbols and including them, if they are defined elsewhere?
I.E, simulating Eclipse's auto-include for Java programs (except not
actually altering the source)?
Template Haskell?
Is it possible to use Template Haskell to pre-analyze a code, searching
for undefined symbols and including them, if they are defined elsewhere?
I.E, simulating Eclipse's auto-include for Java programs (except not
actually altering the source)?
alpha blending in opengl es not working
alpha blending in opengl es not working
I'm trying to vary the transparency of a texture drawn onto a quad, the
code below works fine except the alpha set with glColor4f has no effect.
What are the possible reasons for this? Is it likely to be a gl setting
somewhere else in the program?
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_COLOR, GL_ONE_MINUS_SRC_ALPHA);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, textureId);
glColor4f(1.0f, 1.0f, 1.0f, 0.3f);
glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, 0, quadVertices);
glVertexAttribPointer(normalHandle, 3, GL_FLOAT, GL_FALSE, 0, quadNormals);
glVertexAttribPointer(textureCoordHandle, 2, GL_FLOAT, GL_FALSE, 0,
quadTexCoords);
glEnableVertexAttribArray(vertexHandle);
glEnableVertexAttribArray(normalHandle);
glEnableVertexAttribArray(textureCoordHandle);
glUniformMatrix4fv(mvpMatrixHandle, 1, GL_FALSE,
(GLfloat*)&modelViewProjectionButton.data[0] );
glDrawElements(GL_TRIANGLES, NUM_QUAD_INDEX, GL_UNSIGNED_SHORT, quadIndices);
glDisableVertexAttribArray(vertexHandle);
glDisableVertexAttribArray(normalHandle);
glDisableVertexAttribArray(textureCoordHandle);
I'm trying to vary the transparency of a texture drawn onto a quad, the
code below works fine except the alpha set with glColor4f has no effect.
What are the possible reasons for this? Is it likely to be a gl setting
somewhere else in the program?
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_COLOR, GL_ONE_MINUS_SRC_ALPHA);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, textureId);
glColor4f(1.0f, 1.0f, 1.0f, 0.3f);
glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, 0, quadVertices);
glVertexAttribPointer(normalHandle, 3, GL_FLOAT, GL_FALSE, 0, quadNormals);
glVertexAttribPointer(textureCoordHandle, 2, GL_FLOAT, GL_FALSE, 0,
quadTexCoords);
glEnableVertexAttribArray(vertexHandle);
glEnableVertexAttribArray(normalHandle);
glEnableVertexAttribArray(textureCoordHandle);
glUniformMatrix4fv(mvpMatrixHandle, 1, GL_FALSE,
(GLfloat*)&modelViewProjectionButton.data[0] );
glDrawElements(GL_TRIANGLES, NUM_QUAD_INDEX, GL_UNSIGNED_SHORT, quadIndices);
glDisableVertexAttribArray(vertexHandle);
glDisableVertexAttribArray(normalHandle);
glDisableVertexAttribArray(textureCoordHandle);
Visual Studio Toolbox - close toolbox
Visual Studio Toolbox - close toolbox
I wonder if ther is a way of confirming selection of a tool from MS VS
Toolbox / close toolbox. The opposite of:
ctrl+w .. ctrl+x
and
ctrl + alt + x
What I find really annoying is when I have to add an association between
two entities in model designer, and the one that I want to start with is
hidden behind toolbox.
If so, I have to use e.g. scrollbar to make toolbox loose focus.
Is there a way to confirm that I want to use selected control and hide the
toolbox?
(like shift+esc in VS6) ?
I wonder if ther is a way of confirming selection of a tool from MS VS
Toolbox / close toolbox. The opposite of:
ctrl+w .. ctrl+x
and
ctrl + alt + x
What I find really annoying is when I have to add an association between
two entities in model designer, and the one that I want to start with is
hidden behind toolbox.
If so, I have to use e.g. scrollbar to make toolbox loose focus.
Is there a way to confirm that I want to use selected control and hide the
toolbox?
(like shift+esc in VS6) ?
Tuesday, 1 October 2013
Import updating CSV into SQL Server
Import updating CSV into SQL Server
I'm looking for a simple solution (beginner to SQL) to allow the import of
data from my .csv file to my SQL DB.
I have a third party program that is updating my .csv file every 30
seconds and I want to put that updating information into my SQL DB. I
tried the importing & exporting wizard but it didn't work due to the .csv
file being utilized by the other third party program.
Getting the information into the SQL DB doesn't need to be in real time it
could just retrieve all the information when opening a saved sql query
file.
Thank you!
I'm looking for a simple solution (beginner to SQL) to allow the import of
data from my .csv file to my SQL DB.
I have a third party program that is updating my .csv file every 30
seconds and I want to put that updating information into my SQL DB. I
tried the importing & exporting wizard but it didn't work due to the .csv
file being utilized by the other third party program.
Getting the information into the SQL DB doesn't need to be in real time it
could just retrieve all the information when opening a saved sql query
file.
Thank you!
Using c dynamic link library in javascript program
Using c dynamic link library in javascript program
I want to use c dll in my javascript code.
Is that possible to do that using node ?
Thanks!
I want to use c dll in my javascript code.
Is that possible to do that using node ?
Thanks!
Repairing CentOS files permission
Repairing CentOS files permission
I've screwed my CentOS 6 server. I've ran chmod on a few symlinks and
changed permissions important file such those in /bin and all commands
even clear says Permission Denied. Now It is unable to boot.
How do I restore permissions?
I've screwed my CentOS 6 server. I've ran chmod on a few symlinks and
changed permissions important file such those in /bin and all commands
even clear says Permission Denied. Now It is unable to boot.
How do I restore permissions?
Find $f'(0)$ for $f(x)=?iso-8859-1?Q?=3D?=(2x+1)^3(3x+3)^2$. math.stackexchange.com
Find $f'(0)$ for $f(x)=(2x+1)^3(3x+3)^2$. – math.stackexchange.com
Find $f'(0)$ for $f(x)=(2x+1)^3(3x+3)^2$. Do I use the chain rule for each
or do I use the derivative product rule first Please Help!!!
Find $f'(0)$ for $f(x)=(2x+1)^3(3x+3)^2$. Do I use the chain rule for each
or do I use the derivative product rule first Please Help!!!
Monday, 30 September 2013
is my working correct? Vector equations and planes.
is my working correct? Vector equations and planes.
Is my working correct with regards to the following question? Any feedback
is appreciated.
Question: Find a vector equation for the plane that passes through the
points $A(1, 1,a),B(2, 0,−1)$ and $C(−2, 1,−1)$. If a
has the value $−1$, what can you say about the plane?
Is my working correct?
Vector $BA = <-1 , 1, 1+a>$ and vector $CA=<3, 0, 1+a>$
A normal vector to the plane $ABC$ is the vector product
$$n=BA x CA =<1+a, 4(1+a), - 3> $$
A vector equation for the plane is
$$r.n = (2,0,-1).(1+a, 4(1+a), -3) =5+2a$$
If $a=-1$ the plane has equation $r.(0,0,-3) = 3$
which has Cartesian equation $z=-1$ and this is a plane parallel to the
$x-y$ plane.
Is my working correct with regards to the following question? Any feedback
is appreciated.
Question: Find a vector equation for the plane that passes through the
points $A(1, 1,a),B(2, 0,−1)$ and $C(−2, 1,−1)$. If a
has the value $−1$, what can you say about the plane?
Is my working correct?
Vector $BA = <-1 , 1, 1+a>$ and vector $CA=<3, 0, 1+a>$
A normal vector to the plane $ABC$ is the vector product
$$n=BA x CA =<1+a, 4(1+a), - 3> $$
A vector equation for the plane is
$$r.n = (2,0,-1).(1+a, 4(1+a), -3) =5+2a$$
If $a=-1$ the plane has equation $r.(0,0,-3) = 3$
which has Cartesian equation $z=-1$ and this is a plane parallel to the
$x-y$ plane.
Derivatives and tangent to the line of a curve
Derivatives and tangent to the line of a curve
Find the equations of all tangent lines to the curve y=x/(x+1) that
intersect the point (1,2). Note that the point (1,2) does not lie on the
curve. Please simplify your final answer as much as possible.
This is what I have done so far. I don't know if it is correct.
1/(x+1)= -x-2/(x-1) [cross-multiplied] to get, x-1=-x^2 -3x -2
I made it equal to zero to get a quadratic equation of x^2 + 4x + 1 = 0 to
solve for x I got x = -2 +- root 3
I dont know what to do next.
Find the equations of all tangent lines to the curve y=x/(x+1) that
intersect the point (1,2). Note that the point (1,2) does not lie on the
curve. Please simplify your final answer as much as possible.
This is what I have done so far. I don't know if it is correct.
1/(x+1)= -x-2/(x-1) [cross-multiplied] to get, x-1=-x^2 -3x -2
I made it equal to zero to get a quadratic equation of x^2 + 4x + 1 = 0 to
solve for x I got x = -2 +- root 3
I dont know what to do next.
php preg_match_all get string between two same element
php preg_match_all get string between two same element
please, i want to get every string between two same element (only strong,
not between strong and /strong).
Example string:
<strong>NAME1</strong><br />Some text, some text<br />
<strong>NAME2</strong><br />Some text2, some text2<br />
<strong>NAME3</strong><br />Some text3, some text3<br />
I try this one:
preg_match_all("'<strong>(.*?)<strong>'si", $text, $match);
but result is:
<strong>NAME1</strong><br />Some text, some text<br /><strong>
<strong>NAME3</strong><br />Some text3, some text3<br />
,,NAME2" with ,,some text2" missing, why?
Thank's a lot, Regards, Lukas
please, i want to get every string between two same element (only strong,
not between strong and /strong).
Example string:
<strong>NAME1</strong><br />Some text, some text<br />
<strong>NAME2</strong><br />Some text2, some text2<br />
<strong>NAME3</strong><br />Some text3, some text3<br />
I try this one:
preg_match_all("'<strong>(.*?)<strong>'si", $text, $match);
but result is:
<strong>NAME1</strong><br />Some text, some text<br /><strong>
<strong>NAME3</strong><br />Some text3, some text3<br />
,,NAME2" with ,,some text2" missing, why?
Thank's a lot, Regards, Lukas
center bootstraps nav items
center bootstraps nav items
I add a new class to ul and try to style it with margin: 0 auto and
text-align: center but doesn't work..
<section class="navbar navbar-default">
<ul class="nav navbar-nav">
<li class="active"><a href="index.php">Home</a></li>
<li><a href="venue.php">Venue</a></li>
<li><a href="schedule.php">Schedule</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle"
data-toggle="dropdown">Artists <span
class="caret"></span></a>
<ul class="dropdown-menu" role="menu"
aria-labelledby="dropdownMenu">
<li><a href="artists.php" tabindex="-1">All
Artists</a></li>
<li class="divider"></li>
<li><a href="#" tabindex="-1">1st</a></li>
<li><a href="#" tabindex="-1">2nd</a></li>
<li><a href="#" tabindex="-1">3rd</a></li>
</ul>
</li>
<li><a href="Register.php">Register</a></li>
</ul>
</section>
I add a new class to ul and try to style it with margin: 0 auto and
text-align: center but doesn't work..
<section class="navbar navbar-default">
<ul class="nav navbar-nav">
<li class="active"><a href="index.php">Home</a></li>
<li><a href="venue.php">Venue</a></li>
<li><a href="schedule.php">Schedule</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle"
data-toggle="dropdown">Artists <span
class="caret"></span></a>
<ul class="dropdown-menu" role="menu"
aria-labelledby="dropdownMenu">
<li><a href="artists.php" tabindex="-1">All
Artists</a></li>
<li class="divider"></li>
<li><a href="#" tabindex="-1">1st</a></li>
<li><a href="#" tabindex="-1">2nd</a></li>
<li><a href="#" tabindex="-1">3rd</a></li>
</ul>
</li>
<li><a href="Register.php">Register</a></li>
</ul>
</section>
Sunday, 29 September 2013
jQuery Waypoint: FadeIn - FadeOut effect on scroll
jQuery Waypoint: FadeIn - FadeOut effect on scroll
I'm trying to create a fadeIn and fadeOut effect with elements on scroll.
I'm told this can be done with WayPoint. I've tried a variety of things,
but nothing seems to work, no fade in, no fade out, and no errors in the
console. Here is what I'm currently using:
<script type='text/javascript'>
$(window).load(function(){
$("#top-section").waypoint(function(){
$(this).fadeIn('slow');
},{
offset: 'bottom-in-view'
});
$(this).fadeOut('slow');
},{
offset: 'top-in-view'
});
});
</script>
I'm trying to create a fadeIn and fadeOut effect with elements on scroll.
I'm told this can be done with WayPoint. I've tried a variety of things,
but nothing seems to work, no fade in, no fade out, and no errors in the
console. Here is what I'm currently using:
<script type='text/javascript'>
$(window).load(function(){
$("#top-section").waypoint(function(){
$(this).fadeIn('slow');
},{
offset: 'bottom-in-view'
});
$(this).fadeOut('slow');
},{
offset: 'top-in-view'
});
});
</script>
Pass a generic Object to a list in a method - JAVA
Pass a generic Object to a list in a method - JAVA
I've two question, They may be silly questions but it got me confused now.
QUESTION 1:
I've this code:
private List<Car> carList;
public void setData(List<Object> list)
{
this.carListist = list;
}
But on this.carList = list I get a compiling error: incompatible types,
required: List<Car> but found List<Object>
My question is, why this error? Isn't List a list of objects type Car? So
why doesn't it accept an Object there?
QUESTION 2: I change the above code to the following and the error goes away:
private List<Object> carList;
public void setData(List<Object> list)
{
this.carListist = list;
}
public Object getValueAt(int row, int column) {
Car car = carList.get(row); //Compiling error here
switch(column)
{
(...)
}
(..)
Ther compiling error (signed in the code comment) is incompatible types,
required Car but found Object What I don't understand is, now list is
defined as an object list. Car is an object. Why car, as being an object,
is not accepted?
Anyway to fix this for both question 1 and 2?
I've two question, They may be silly questions but it got me confused now.
QUESTION 1:
I've this code:
private List<Car> carList;
public void setData(List<Object> list)
{
this.carListist = list;
}
But on this.carList = list I get a compiling error: incompatible types,
required: List<Car> but found List<Object>
My question is, why this error? Isn't List a list of objects type Car? So
why doesn't it accept an Object there?
QUESTION 2: I change the above code to the following and the error goes away:
private List<Object> carList;
public void setData(List<Object> list)
{
this.carListist = list;
}
public Object getValueAt(int row, int column) {
Car car = carList.get(row); //Compiling error here
switch(column)
{
(...)
}
(..)
Ther compiling error (signed in the code comment) is incompatible types,
required Car but found Object What I don't understand is, now list is
defined as an object list. Car is an object. Why car, as being an object,
is not accepted?
Anyway to fix this for both question 1 and 2?
Control RTMP chunk size - AWS Cloudfront
Control RTMP chunk size - AWS Cloudfront
I am developing a website where I am using flow player flash as my video
player. I am using AWS(EC2 + S3 + Cloudfront) to manage and store my
files. Using cloudfront RTMP I have setup my video streaming.
But the streaming is bit slow, like the buffer takes too long to play
small size of video, I have tested my internet speed, and rather then my
website other websites like youtube, vimeo works perfectly fine.
I have enabled cache on cloudfront and also the locations are set for best
performance.
Some how is it possible to control chunks size delivered from cloudfront?
I am developing a website where I am using flow player flash as my video
player. I am using AWS(EC2 + S3 + Cloudfront) to manage and store my
files. Using cloudfront RTMP I have setup my video streaming.
But the streaming is bit slow, like the buffer takes too long to play
small size of video, I have tested my internet speed, and rather then my
website other websites like youtube, vimeo works perfectly fine.
I have enabled cache on cloudfront and also the locations are set for best
performance.
Some how is it possible to control chunks size delivered from cloudfront?
My first app can't inlate xml file error
My first app can't inlate xml file error
My first android app is according "Building a Simple User Interface". but
when I run it on my device, it gave me out errors,
E/AndroidRuntime(30660): FATAL EXCEPTION: main
E/AndroidRuntime(30660): java.lang.RuntimeException: Unable to start
activity
ComponentInfo{com.example.myfirstapp/com.example.myfirstapp.MainActivity}:
android.view.InflateException: Binary XML file line #7: Error inflating
class ViewText
E/AndroidRuntime(30660): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(30660): Caused by: android.view.InflateException: Binary
XML file line #7: Error inflating class ViewText
but, when I look into the loaded xml, it don't have any TextView element
in my layout file. my layout file is all as following,
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<EditText android:id="@+id/edit_message"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/edit_message"
/>
<Button android:id="@+id/send_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button_send"
android:onClick="sendMessage" />
</LinearLayout>
I am confused, what's the problem? thanks your help.
My first android app is according "Building a Simple User Interface". but
when I run it on my device, it gave me out errors,
E/AndroidRuntime(30660): FATAL EXCEPTION: main
E/AndroidRuntime(30660): java.lang.RuntimeException: Unable to start
activity
ComponentInfo{com.example.myfirstapp/com.example.myfirstapp.MainActivity}:
android.view.InflateException: Binary XML file line #7: Error inflating
class ViewText
E/AndroidRuntime(30660): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(30660): Caused by: android.view.InflateException: Binary
XML file line #7: Error inflating class ViewText
but, when I look into the loaded xml, it don't have any TextView element
in my layout file. my layout file is all as following,
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<EditText android:id="@+id/edit_message"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/edit_message"
/>
<Button android:id="@+id/send_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button_send"
android:onClick="sendMessage" />
</LinearLayout>
I am confused, what's the problem? thanks your help.
Saturday, 28 September 2013
inline-block divs next divs containing images being pushed down
inline-block divs next divs containing images being pushed down
Pleas look at my fiddle:
http://jsfiddle.net/2uJKR/70/
The divs containing text are being pushed down, I want all 4 to be aligned
horizontally.
What is missing?
HTML
<div class="bar">
<div class="element image">
<img src="http://www.itsalif.info/blogfiles/video-play/vthumb.jpg"/>
</div>
<div class="element image">
<img src="http://www.itsalif.info/blogfiles/video-play/vthumb.jpg"/>
</div>
<div class="element">
TEXT 1
</div>
<div class="element ">
TEXT 2
</div>
</div>
CSS
.bar {
position:relative;
margin:1px auto 1px auto;
width:425px;
height:50px;
border:1px solid red;
}
.element {
display:inline-block;
width:100px;
height:50px;
border:1px solid blue;
}
.image img {
display:block;
margin:0 auto;
margin-top:10px;
width:30px;
height:30px;
}
Pleas look at my fiddle:
http://jsfiddle.net/2uJKR/70/
The divs containing text are being pushed down, I want all 4 to be aligned
horizontally.
What is missing?
HTML
<div class="bar">
<div class="element image">
<img src="http://www.itsalif.info/blogfiles/video-play/vthumb.jpg"/>
</div>
<div class="element image">
<img src="http://www.itsalif.info/blogfiles/video-play/vthumb.jpg"/>
</div>
<div class="element">
TEXT 1
</div>
<div class="element ">
TEXT 2
</div>
</div>
CSS
.bar {
position:relative;
margin:1px auto 1px auto;
width:425px;
height:50px;
border:1px solid red;
}
.element {
display:inline-block;
width:100px;
height:50px;
border:1px solid blue;
}
.image img {
display:block;
margin:0 auto;
margin-top:10px;
width:30px;
height:30px;
}
Wordpress 3 parent pages are showing posts not their page content.
Wordpress 3 parent pages are showing posts not their page content.
I have a Wordpress 3.6.1 site at: http://ileap.org/
My top level pages (except the home page ) are showing posts not their
given page content. In the backend the content is right. The weird thing
is that the child pages work fine. Clicking around the nav to any child
page you get the appropriate content, its just the parents. Permalinks are
set to just Post Name, and I have changed the setting saved and then reset
to make sure its not that.
This has stumped me for 2 days now. any ideas?
I am running the metrovibes theme.
I have a Wordpress 3.6.1 site at: http://ileap.org/
My top level pages (except the home page ) are showing posts not their
given page content. In the backend the content is right. The weird thing
is that the child pages work fine. Clicking around the nav to any child
page you get the appropriate content, its just the parents. Permalinks are
set to just Post Name, and I have changed the setting saved and then reset
to make sure its not that.
This has stumped me for 2 days now. any ideas?
I am running the metrovibes theme.
this.parentNode.parentNode.removeChild is removing the parent
this.parentNode.parentNode.removeChild is removing the parent
In my code the function displayUserTable appends some divs called
tUserBlock to the main div called centralWindow. When you click on a
tUserBlock a div pops up from the tUserBlock.onclick function called
userTableClickListener. I want to be able to close that popup when you
click on it so I've added an onclick function called userPopupClick with
the following code inside:
this.parentNode.parentNode.removeChild(this.parentNode);
But when it's clicked the centralWindow div (the main div) disappears
along with all the contents. But I just want to hide the popup div. I'm
not sure what I'm doing wrong?
Here's the code, the popup part is towards the bottom:
function displayUserTable() {
var tTop = 15;
var tUserBlock = [];
for (var z = 0; z < (UserData.length); z++) {
tUserBlock[z] = document.createElement('div');
tUserBlock[z].className = 'usertable_item';
tUserBlock[z].id = ('userblock' + z);
tUserBlock[z].style.width = "388px";
tUserBlock[z].style.height = "35px";
tUserBlock[z].style.top = tTop + "px";
tUserBlock[z].style.left = "25px";
tUserBlock[z].userID = z;
tUserBlock[z].onclick = userTableClickListener;
centerWindow.appendChild(tUserBlock[z]);
}
}
function userTableClickListener() {
var tID = this.userID;
var tPopup = document.createElement('div');
tPopup.className = 'usertable_popup';
tPopup.id = 'usertable_popup';
tPopup.onclick = userPopupClick;
centerWindow.appendChild(tPopup);
}
function userPopupClick() {
this.parentNode.parentNode.removeChild(this.parentNode);
}
In my code the function displayUserTable appends some divs called
tUserBlock to the main div called centralWindow. When you click on a
tUserBlock a div pops up from the tUserBlock.onclick function called
userTableClickListener. I want to be able to close that popup when you
click on it so I've added an onclick function called userPopupClick with
the following code inside:
this.parentNode.parentNode.removeChild(this.parentNode);
But when it's clicked the centralWindow div (the main div) disappears
along with all the contents. But I just want to hide the popup div. I'm
not sure what I'm doing wrong?
Here's the code, the popup part is towards the bottom:
function displayUserTable() {
var tTop = 15;
var tUserBlock = [];
for (var z = 0; z < (UserData.length); z++) {
tUserBlock[z] = document.createElement('div');
tUserBlock[z].className = 'usertable_item';
tUserBlock[z].id = ('userblock' + z);
tUserBlock[z].style.width = "388px";
tUserBlock[z].style.height = "35px";
tUserBlock[z].style.top = tTop + "px";
tUserBlock[z].style.left = "25px";
tUserBlock[z].userID = z;
tUserBlock[z].onclick = userTableClickListener;
centerWindow.appendChild(tUserBlock[z]);
}
}
function userTableClickListener() {
var tID = this.userID;
var tPopup = document.createElement('div');
tPopup.className = 'usertable_popup';
tPopup.id = 'usertable_popup';
tPopup.onclick = userPopupClick;
centerWindow.appendChild(tPopup);
}
function userPopupClick() {
this.parentNode.parentNode.removeChild(this.parentNode);
}
Subscribe to:
Posts (Atom)