phfilly 26 Junior Poster

Thank you for the detailed reply Airshow. This makes a lot more sense to me now!

phfilly 26 Junior Poster

I think Im misunderstanding something here - I normally work in PHP and think I'm missing something small. My final array tmp is empty and displays as ",,,,,,,,,,,,,,,," . It seems to me my tmp array might be emptied somewhere or the scope gets reset for some reason. I'm using this as coordinates from a table where you can select table rows and posting to a webservice but my array seem to be erroneous.

var length = $("#arrayCount").html(); 
var letters = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];
var col = getSelectedColumn(); //for example sake lets say "B" is the selected column
var row = getSelectedRow(); //selected rows will be from "11" - "16"
var columnIndexStart = letters.indexOf(col[0]);
var tmp = [];
for(var i = row[0]; i <= row[1]; i++)   //rows[0] = 11 and rows[1] = 16
{
    tmp[i] = [];
    for(var j = columnIndexStart; j < letters.length; j++)  //columns and starts at index 1 if we work with "B"
    {
        var val = $("#" + i + "_" + letters[j]).html(); //using the row and letters as the associated DOM elements ID. Easier to retrieve it's HTML then.
        if(val != undefined)
        {
            console.log("Index [" + i + "]['" + letters[j] + "'] = " + val); //works perfectly and prints as it should.
            tmp[i]['"'+letters[j]+'"'] = val; //using quotes to save letters? Is this preferred?
        }
    }
}
console.log('Final Array: ' + tmp); //empty??
console.log('Final Array: ' + tmp[14]['G']); //testing HTML output. But is undefined. 
return tmp;

Any help will be much appreciated.

phfilly 26 Junior Poster

No worries after a few hours of searching I found an awesome plugin and a few code pens.

http://matthew.wagerfield.com/parallax/
http://codepen.io/samarkandiy/pen/behFa
http://codepen.io/dghez/pen/ItxKE

Enjoy :)

phfilly 26 Junior Poster

Hi guys,

I was wondering if anyone can pin-point me to the right direction. I want to implement this css translate 3d effect does anyone maybe know of a resource(s) I can work through to do this? I've been searching for related content and haven't been able to find this "hover translate 3d effect" anywhere.

Reference link: http://demo.themeisle.com/parallax-one/

PS- I understand that the developer used 2 or 3 layers to achieve that "look" I just want to implement a similar effect of when you hover of the front image that it moves/animates with your mouse.

Thanks

phfilly 26 Junior Poster

Use Session variables to store the cart items id's so everytime you load the cart you get the item details and display it. This is now if I understand you correctly in saying that when you move from page to page you loose your cart items?

phfilly 26 Junior Poster

It could be your Glyphicons isn't setup correctly. Check the URL in the bootstrap.css leading to the Glyphicon file and that the files are actually in the directory.

phfilly 26 Junior Poster

Is there another form on the page with the same field name/ids?

phfilly 26 Junior Poster

The videos can act as portfolio items and then on this page etc. University you'll have the ability to display all portfolio items to be arranged by latest release date. Problem is though you'll need to be sure that your wordpress theme supports a portfolio section and that you'll be able to generate a shortcode for it.

phfilly 26 Junior Poster

Do you get any php/db/js error? You can switch it on by adding this to the php file you're using -> error_reporting(E_ALL); ini_set('display_errors', '0');

phfilly 26 Junior Poster

Hi - I've encountered something similar before and it was beyond frustrating especially when I didn't get an error aswell.

Someone pointed out that it was indeed the file permissions and I was using FileZilla at the time. So I changed the folder's permission to where I'm uploading to 777 and it all worked 100%. Maybe this can work for you.

phfilly 26 Junior Poster

Thanks raevel I'm going to take a look at that IN clause approach. I Will mark it completed if it works.

phfilly 26 Junior Poster

Hi everyone,

I'm wondering about a potential problem I might get. My problem is lets say I have 2 tables one called speakers and clients. In the client table the client has the speaker ID's of 1,5,8(SAVED in a STRING field) - so I'm using explode() to get the values.

So now I have to call the speaker table 3 times to get the values of each speaker. This introduces the problem that it will get very expensive if there is alot of users online wouldn't it?

Is there an alternative to calling a table from an array of items or something?

I'm not too clued up about all the php approaches to this so any help will be appreciated!

I'm using mysql for the db.

phfilly 26 Junior Poster

Yes exactly like that! Can this produce problems?

phfilly 26 Junior Poster

Part is an id which is received from the image.

phfilly 26 Junior Poster

Still the same 'error' occurs...

phfilly 26 Junior Poster

Hi all,

I'm not too familiar with Ajax but I believe I grasp the basics. So I'm sending an id which I retrieve from an element to a php page but I can't seem to retrieve the id being send.

My javascript:

function ListPart(part) {
        var imgdata = part;
        $.ajax({
            url: "components.php",
            type: "POST",
            data: { id : imgdata },
            dataType: "text",
            success: function(imgdata) {
                alert(imgdata);
            }
        });
        return false;
    }

My components.php:

<?php
    if(isset($_POST["id"])) {
        echo $_POST["id"];
    } else {
        echo "not found";
    }
?>

Am I missing something small? Also I would like to know in that alert(imgdata) I get the whole document's html and not just the id? Is there a reason for this?

PS: The "not found" is not even being displayed. Although the alert in the success function does execute.

Any help will be appreciated!

Thanks.

phfilly 26 Junior Poster

Wow it definitely seems like you 'tried'...

phfilly 26 Junior Poster

So after some help from friends - This worked in the end:

onclick=test(this)

jquery/js:

function test(obj){
    alert(obj.outerHTML);
};
phfilly 26 Junior Poster

Thanks for your quick response JorgeM!

I actually thought with the html() function I will be able to retrieve the <img> tag and all of it's properties with it.

Will it be possible to call the onclick via the anchor tag and then try to get it's child's html? I've tried this but wasn't able to let it work.

I'll try the attr route in a bit - thanks!

phfilly 26 Junior Poster

Hi guys,

Can anyone please help me with this simple error. Jquery is not my strongest suite but I feel like this is something small that I'm missing. With the code below I get the error 'undefined'.

html:

<a href='#' ><img src= "./images/1.jpg" width= '200px' id="2" rel="arm1" onclick = 'test()' /></a>

Jquery:

function test(){
    alert($(this).html());
};

What I want is the HTML code of the img tag being clicked on. Is there another way to do this?

So I've tried the following and it doesn't work aswell: I've added the onclick to the ahref tag aswell.(error : undefined) I've tried passing by 'event' as a parameter. (error stating ev is not declared) when trying to get its html().

PS I do not want to use the id as a onclick function!

Anyhelp will be very much appreciated!

Thanks!

phfilly 26 Junior Poster

Thanks I'll look into that.

phfilly 26 Junior Poster

Hi guys,

Was wondering if you could help me please.

So I have a list of menu elements from which I can drag elements into a div tag. This all works fine. But I'm struggling to replace the elements with each other. So say for instance I already have an img in that one div tag and I want to replace that img with another. At the moment it only appends it instead of swapping the two.

I've tried various methods but can't seem to get it...

Below follows the drop() function :

//DraggedImageData is just the HTML of an image

function drop(ev){
            ev.preventDefault();
            var data = ev.dataTransfer.getData("text/html", ev.target.id);  //div to drop id    

                if(DraggedElement == ev.target.id)
                {
                    if(ev.target.hasChildNodes())
                    {
                        //this is where i don't know what to add 
                    }
                    else{
                        $(ev.target).append(DraggedImageData);  
                    }       

                }
        }

I've tried document.getElementById(ev.target.id).replaceWidth(DraggedImageData); but didnt work.

Any help will be appreciated!

phfilly 26 Junior Poster

This is also quite nice

phfilly 26 Junior Poster

The code seems fine to me.

Just a quick question - are you testing it on an already live website or are you testing it via your localhost?

phfilly 26 Junior Poster

For problem 1:

It could be that index 4 actually means that the max size is 5. Seeing as an index can start at 0.

This can happen in line 2 where it looks for the index which isn't there.

Not excatly sure how you can get an error in problem 2? Do you get an error at line 9?

phfilly 26 Junior Poster

Thank you so much! That worked 100%!

phfilly 26 Junior Poster

Hi!

I have a problem with the unlink() php function. What I try to do is to delete a certain file in a directory. Now the function works fine. But when I call it then it deletes ALL the files inside of that directory. What I want is for it to delete that certain file which the user can select from a list.

I display all the files with php and beside it is a 'X' ahref link which doesn't seem to be identified with that file next to it. This 'X' is used to delete the file.

echo "$file <a title='Delete book' href='#' onclick=".delete($file).">X</a>";

This line prints all the files listed in the directory. (It's in a while loop)

Here is the delete function:

function delete($var){
     $link = './book/'.$var;
     unlink($link);
 }

I'm not sure how to identify the 'X' with the book next to it. Because at the moment it seems 'X' is linked to all the files.

Any help will be appreciated!

Thanks!

phfilly 26 Junior Poster

My bad getter *method. :)

That is correct what you said - it is more just what I would've done and that is why I suggested it.

phfilly 26 Junior Poster

There is a lot of neat javascript/jquery plugins you can download for free. And I know HTML 5 also supports a progress bar if you want to read up on that.

But the ones you're going for would be like these if I understand you correctly:

JS - http://s3.envato.com/files/2526201/index.html
Check under "Untypical usage: poll result" there is a static progressbar example with code!

Jquery example - http://jqueryui.com/progressbar/

Hope this helps!

phfilly 26 Junior Poster

Okay,in the Player function why do you return String[]?

When you return a String it is just return String. When you return a Char that has more than one characters in then your return the array of characters it's not a array of string.

Also don't make the function static. Create a private variable and then you make that variable static if you want to save that players 'type'. Then also playerChar won't be declared in the scope of the main? If you want to return that string you need to define a getter function to return the String....

phfilly 26 Junior Poster

Execute the code as the compiler would but do it on paper....Or you can use netbeans and use the 'break' function to step line by line through your code and see how the variable changes/updates.

phfilly 26 Junior Poster

Yes, for mo-vember!

Have you ever punched someone?

phfilly 26 Junior Poster

If you make any function within that class pure virtual then you can't create a object of that class. If I understand you correctly or make the inheretence private like Ancient Dragon said.

phfilly 26 Junior Poster

Why would anyone want to help you if you ask/request it like that...Post your code that you're struggling with or show where you get errors in your code.

phfilly 26 Junior Poster

You should try changing the position from inherit to absolute! Then you would have much more control over the div tag.

Like for example:

#cd,new{
    position:absolute;
    left: 15%;
    top: 20%;
    etc...
}

Hope this helps!

phfilly 26 Junior Poster

Thanks for the reply!

Yes I did expect the php to echo the value to the screen. Because later I want to save that variable to a database so I just wanted to test if the server correctly received the value.

Thanks for the help!

phfilly 26 Junior Poster

So after some research I saw that I could do this via a cookie request. Very simple and hopefully it won't give any errors in the future.

document.cookie = 'pageNum='+pageNum;

then on the php:

$pageNum = $_COOKIE['pageNum'];
echo "Page numbers: $pageNum";

If someone could maybe still respond to the previous comment! That would be great! As I'm curious to know why it didn't work.

Will mark it as solved after I got an answer :)

phfilly 26 Junior Poster

Thank you for the response.

@rouf - I can't change it to ampersand as I'm using javascript and not jquery. I've tried the send(null) which did unfortunately not work.

@pzuurveen - Thank you for pointing that out in your first point. I wanted to handle the data on the php side that I didn't think yet what to do with it when it returned.

It's weird now because on the php side I get that undefined index error of the variable pageNum. But with the response text it prints out the value correctly...Which is confusing. So it means that the variable data was never reached by the php?

phfilly 26 Junior Poster

Hi all!

I have a problem which I can't seem to fix. I would like to know is it possible to send a normal JS variable to a php page. I've tried the following and nothing seems to work.

<input type="submit" value="Bookmark" onclick="bookmark();">

function bookmark() {
  var pageNum = 2;
  var xmlhttp;
  if (window.XMLHttpRequest)
  {
     xmlhttp = new XMLHttpRequest();
  }else{
     alert("Not assigned!");
  }

   xmlhttp.open("GET", "Bookmark.php?pageNum="+pageNum, true);
   xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); with or without this it doesn't work
   xmlhttp.send();
   alert("Bookmark send!");
}

Then in the php:

$pageNum = $_GET['pageNum']; 
echo "Page numbers:" + $pageNum;

I've tried post aswell and I've tried

var pageNum = 'pageNum=' + 2;
xmlhttp.open("POST", "Bookmark.php", true);
xmlhttp.send(pageNum);

php:

$pageNum = $_POST['pageNum'];
echo "Page numbers:" + $pageNum;

any help will be appreciated!

Thanks!

phfilly 26 Junior Poster

I found a way which does the part - thanks for the help. Was just something small.

var title = $(this).find('dc\\:title').text();

I have the controll I wanted now.

phfilly 26 Junior Poster

Thanks for the replies!

The xml code is used as an e-book standard to display meta data. I did try your method but I seem to get 'undefined' and 'getAttribute()' doesn't exist error in FF version 15. So I tried this:

Using this in the ajax function below.

                               var title =  xmlDoc.getElementsByTagNameNS(namespace, 'creator');
                               alert(title);           //object HTMLCollection error (can't be an array)
                               alert(title.nodeValue); //undefined

And sometimes it may be like this in the xml @LastMitch <dc:title id="title">Moby-Dick</dc:title> so I can't find the value by attribute.

@pritaeas I actually did look at that forum aswell but it is a bit outdated and some code doens't work anymore on the new jquery. So after testing various cases this seemed to actually give me a solid output.

New Code:

function showMeta() {                 
                $.ajax({
                    type: "GET",
                    url: "boek/" + pathM,
                    dataType: "xml",
                    success: function(xml) {
                            $(xml).find('metadata').each(function(){
                                var meta = $(this).text();
                                alert(meta);
                            });
                    }
                });

So this outputs ALL the text in that metadata tag...I would like to have more control over it. To say like "Author: Herman Melville and Title: Moby-Dick". I've tried ALOT of different methods but non actually found the child nodes and it's text. Do you maybe have any advice on how to achieve this?

This really baffles me as this namespace makes it nearly impossible to find child elements.

phfilly 26 Junior Poster

Hi all!

I have a problem that I've been struggling with for quite sometime. In short I've successfully parsed a xml file from a string. But I can't seem to access the correct elements. The thing is I'm reading the xml file data via javascript but in the xml file the nodes use namespaces. To get an element that doesn't have a namespace can I easily access.

In the xml file:

<?xml version="1.0" encoding="UTF-8"?>
<package xmlns="http://www.idpf.org/2007/opf" version="3.0" xml:lang="en" unique-identifier="pub-id" prefix="cc: http://creativecommons.org/ns#">
  <metadata xmlns:dc="http://purl.org/dc/elements/1.1/">
    <dc:title id="title">Moby-Dick</dc:title>
    <meta refines="#title" property="title-type">main</meta>
    <dc:creator id="creator">Herman Melville</dc:creator>
    <meta refines="#creator" property="file-as">MELVILLE, HERMAN</meta>
    <meta refines="#creator" property="role" scheme="marc:relators">aut</meta>
    <dc:identifier id="pub-id">code.google.com.epub-samples.moby-dick-basic</dc:identifier>
    <dc:language>en-US</dc:language>
    <meta property="dcterms:modified">2012-01-18T12:47:00Z</meta>
    <dc:publisher>Harper &amp; Brothers, Publishers</dc:publisher>
    <dc:contributor id="contrib1">Dave Cramer</dc:contributor>
    <meta refines="#contrib1" property="role" scheme="marc:relators">mrk</meta>
    <dc:rights>This work is shared with the public using the Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0) license.</dc:rights>        
    <link rel="cc:license" href="http://creativecommons.org/licenses/by-sa/3.0/"/>
    <meta property="cc:attributionURL">http://code.google.com/p/epub-samples/</meta>
  </metadata>

My javascript:

xmlDoc = parseXML(XMLString);

var a = xmlDoc.getElementById("creator");
var author = a.getElementsByTagNameNS("http://purl.org/dc/elements/1.1/","creator");

No this is what I've tried and it doens't seem to work. I did search for other options but couldn't find something that helped! If anyone could please help!

phfilly 26 Junior Poster

Thanks for the help!

Cleared up a few things. It's exactly like you said a 3d cube!

phfilly 26 Junior Poster

Thanks Ancient Dragonfor your explenation!

The thing is the class name is Integer. How would one change the implementation so that it creates an object(Integer) in each block in a dynamic 2d array? So it's a pointer pointing to a 2d array. That's why I used 2 for-loops in stead of just one. And yes each dimention is the same size.

Is my way of doing correct as indicated in the first post?

I apologise if my first post was a bit vague!

phfilly 26 Junior Poster

Hi I have trouble with implementing a dynamic two dimensional pointer array on allocating memory for it.

I tried it this way but not sure if it's correct. The array should contain pointers to heap allocated Integer objects

const int size = 10;
Integer *** twoD;

twoD = new Integer**();

for(int i = 0 ; i < size ; i++)
    *twoD[i] = new Integer();
        for(int j = 0 ; j < size ; j++)
            twoD[i][j] = new Integer();

Any help will be appreciated!

phfilly 26 Junior Poster

Ah okay makes sense - thank you for the quick response!

phfilly 26 Junior Poster

int* = needle doesn't make sense and *needle 100 have you even tried running it in a compiler?

phfilly 26 Junior Poster

Hi all!

I just have a quick question about the execution of a copy constructor. This is the code i'm testing my work with as I'm busy learning for a test.

Class file:

Clock :: Clock (int h, int m, int s)
{
    hr = h;
    min = m;
    sec = s;
    cout << " Default constructor " << endl ;
}

Clock :: Clock ( const Clock & c) 
{
    hr = c.hr;
    min = c.min ;
    sec = c.sec ;
    cout << " Copy constructor " << endl ;
}

Clock Clock :: LunchTime () {
    hr = 12;
    min = 0;
    sec = 0;
    return * this ;
}

bool Clock :: equal ( const Clock c)
{
    return hr == c.hr && min == c.min && sec == c.sec ;
}

Then in the main :

int main () {
    Clock c1 (12 ,0 ,0);
    Clock c2;
    c2. LunchTime ();
    if (c1. equal (c2))
        cout << " Times are equal " << endl ;
}

My question is why is it that the c2.LunchTime() triggers the copy constructor? And with the next line if (c1. equal (c2)) it also calls the copy constructor?

Any help will be appreciated!

phfilly 26 Junior Poster

Thanks the responses it helped a lot!

I just want to ask WaltP something.

Do you suggest maybe using a stack especially when you say 'replace' and just insert the answer back in the equation? And you can then more easily get lets say the 'left' and 'right' integers of the '+' sign?

Or did you just use the string?

The thing is the equation is not being inputted, I'm receiving it from a predefined string in my main.c

Just a last thing - I did look at the reverse polish notation. I'm just looking into it on how I'm going test the precedence. Because then the whole thing changes again and the order in which it executes.

Thanks for the help thus far!

phfilly 26 Junior Poster

Thanks for the response!

But the thing is I'm getting the whole expression AND operand all in one string together! I can't split it up as an interger and string :/ What I mean with the split is that I can't read it in as segments like your example!

I need to tokenize it from the string and then do the functions from there.