-
Posts
579 -
Joined
-
Last visited
Posts posted by Drongo_III
-
-
Hi
Thanks for that mate! It's much clearer to me now.
I didn't realise the hover function required a mouseover and mouseout event - for some reason i thought it just executed everything inside.
It all makes sense now
Thank you!
Drongo
I will help you to understand this better.
1. This is saying.. when the user hovers over the li.headlink within the element of id cssdropdown, display all ul elements and li.headlink elements as a block..
2. the jquery hover function accepts 2 arguments, the first argument is a custom handler to handle the onmouseover event.. the second argument controls the onmouseout event, so that code is stating when the mouse is hovered over the element, set the css of the elements ul and li.headlink as block, when the mouse is not hovered over the li.headlink element.. display the ul and li.headlink elements as hidden again..
this link should help as well...
-
Thanks for the post!
Afraid that doesn't quite help me to undersand the logic of the jquery :/ Anyone help?
-
Hi Guys
I feel a bit silly asking this but I've started using a jquery drop down menu script. It's fantastically simple but I don't quite follow these two lines of code or see how it works as I'm not a huge user of jquery.
The jquery is:
$(document).ready(function(){ $('#cssdropdown li.headlink').hover( function() { $('ul', this).css('display', 'block'); }, function() { $('ul', this).css('display', 'none'); }); });
Ok I understand the .hover bit - so when someone hovers over the li.headlink elemenet it will display block. But i am confused about two points
1) The "ul,this" part - is that saying - When someone hovers over li.headlink then display the UL element inside the li.headlink element?
2) In conventional old javascript you'd use onmouseover and onmouseout to trigger the state change from 'block' to 'none'. But to me these lines of code are saying "when someone hovers over li.headlink then display it as a block then display it as none" - which to my poor logic would mean the item should not display at all. I suspect maybe it's a syntax thing and the comma between functions has something to do with it but i'm not sure. Can you someone explain why this works and what it's actually saying?
Sorry to ask such silly questions but I like to understand the things i use and in honesty i don't with this most simple of scripts...
Thanks
Drongo
-
Hi Guys
Bit of a noob question.
I'm building a site that has a transparent content container div (to show background image). However, all the child elements of that div are also turning transparent and i can't seem to stop this.
I tried setting the opacity of child elements but it didn't work.
Anyone got any tips?
I've read around though most of the posts are very old and they all suggest either absolutely positioning everything so there child elements aren't child elements. Or alternatively they suggest using a transparent png - but i kind of wanted to use just CSS. Is there a simple trick or are these my only alternatives?
Thanks,
Drongo
-
Thanks King
That's a good point. I will make sure I express my opinions and get involved as much as possible.
I think i will feel so much better once i meet my competition and get a glimpse of what's to come too. The great unknown is always so much worse than the reality - usually...
To add what Gizmola said, take initiative! Most people are so nervous they forget to answer any questions. I can't tell you how many times I've seen someone that I wanted to hire, but when it came to the group interview they completely bombed it because they didn't say a peep on their own.
-
Cheers guys!
The interview is on monday. So final few days of prep...it's knackering cramming by evening though when you're working flat out all day but gues these are the hopps we have to jump through to progress!
I shall let you all know how it goes.
Hopefully i'll be postnig a big fat smilie face
Drongo
Well either way, once you get done with your interview, tell us how it went.
When is your interview?
-
Thanks Gizmola!
That's really great advice and to be honest helps to relax me a lot!
I think i am getting too caught up worrying about what might be, or how i should put this or that across when really i just need to deomstrate a confident air and an open mindedness to taking on whatever they throw my way.
Really appreciate your advice and i'm very glad i asked
Drongo
I have been involved in scores of group interviews over the years.
My advice is simple:
-Try and be as relaxed as possible. Make eye contact with everyone as much as possible.
-Answer as honestly as you can, and be yourself. Don't get caught up worrying about what you think the right answer is. You have no idea about the agendas and hot buttons of the people involved.
-Make sure you have some "good questions" about the company you're interviewing which shows that you are familiar with what they do, which gets them to talk about themselves and also shows you did your homework
There are probably loaded questions that will lose you the job outright, but you won't know what they are. Overall, in my experience, people are looking for someone who is going to fit in, and be easy to work with, so the impression you really want to make is that you're confident without being arrogant, and yet still a team player who works well with others.
You may get some of those questions that people love to ask like: "Tell me about a time you failed", or "What was a tough problem you had to face at work" and things of that nature, so it helps to rehearse a few of those, so you have a decent story to tell, that shows how you can make lemonade out of lemons.
Just make sure that you remain positive throughout, and avoid any negative discussion about your past workplaces. You might have worked in hell for Sadam, but that's still a "great learning experience" where you learned a lot, and were able to achieve "this amazing success.."
Short of giving programming tests and having people fail miserably, I find that people are looking to hire someone who will come in and make their life easier, and that's really what you want to have them feel about you.
Good luck with the interview!
-
Hi Guys
This is going to sound a bit silly (and possibly off topic entirely) but my motto in life is that if you don't accept your ignorance and ask a question then you'll just be ignorant forever.
So with that in mind....
I'm going for a job with a big web company as a project manager. The interview is going to be a group interview with a handful of candidates.
I've never in my life been a group interview and although i have experience in this field i am naturally quite apprehensive about what to expect - and i want this job so badly i would eat my feet to get it.
So does anyone here work for any big web companies and have you had any experience with group interviews in this setting? Any advice, tips, or suggestions on possible questions and format would be very welcome!
Drongo
-
Worked a treat! Thank you very much
It means you have to change
if ((($_FILES["file"]["type"] == "text/csv"))
to:
if ((($_FILES["file"]["type"] == "application/vnd.ms-excel"))
-
Hi TenDoLLA
I did as you suggested - didn't know that existed. But the result has left me a little confused.
I did :
var_dump($_FILES["file"]["type"]); echo "<br/><br/>"; var_dump($_FILES["file"]["size"]);
And got the result
string(24) "application/vnd.ms-excel" int(50)
Which didn't mean a whole lot to me. I would love an explanation of that.
Any suggestions based on the var dump?
Thanks
Drongo
So the first if is failing, either ($_FILES["file"]["type"] == "text/csv") or ($_FILES["file"]["size"] < 200000) is not matching or both. Try var_dumping these variables to see what they contain to try to figure out why your if clause is failing.
-
Hi Guys
Can someone see where I'm going wrong with this upload script. It's meant to only accept csv files.
when i try it out all i get is is the error "invalid file" but i'm uploading a csv file.
Upload form
<html> <body> <form action="upload.php" method="post" enctype="multipart/form-data"> <label for="file">Filename:</label> <input type="file" name="file" id="file" /> <br /> <input type="submit" name="submit" value="Submit" /> </form> </body> </html>
Upload script
<?php if ((($_FILES["file"]["type"] == "text/csv")) && ($_FILES["file"]["size"] < 200000)) { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; } else { echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />"; if (file_exists("upload/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]); echo "Stored in: " . "upload/" . $_FILES["file"]["name"]; } } } else { echo "Invalid file"; } ?>
Any help would be appreciated.
Drongo
-
Ha thanks Wizard. That makes perfect sense. I was searching around for "file type" not knowing they were called mime types... It all makes sense now
Thank you!
Those start with image/ cause they are images types.
For csv you need to use text/csv
For a list of mime types check here http://en.wikipedia.org/wiki/Internet_media_type
-
Hi Guys
I'm writing a script to allow for file uploads on the front end of a site.
I want to restrict the file upload to csv files only.
I can find examples for images such as
if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/pjpeg")) && ($_FILES["file"]["size"] < 20000)) {Code goes here }
But what do you use for CSV files?
And why does this example use image/ before the file type?
Sorry i know these are newbie questions but still new to this.
thanks
Drongo
-
Well solved this noob problem now!
For anyone who may, at the start of the php career, be similarly perplexed here is what i did...
<?php $builder = "<table>\n"; $row = 0; $handle = fopen("testfile.csv", "r"); while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { if ($row == 0) { // this is the first line of the csv file // it usually contains titles of columns $num = count($data); $builder = $builder . "\n<tr>"; $row++; for ($c=0; $c < $num; $c++) { $builder = $builder . "<td>" . $data[$c] . "</td>"; } $builder = $builder . "</tr>\n\n<tbody>"; } else { // this handles the rest of the lines of the csv file $num = count($data); $builder = $builder . "<tr>"; $row++; for ($c=0; $c < $num; $c++) { $builder = $builder . "<td>" . $data[$c] . "</td>"; } $builder = $builder . "</tr>\n"; } } fclose($handle); $builder = $builder . "</tbody>\n</table>"; echo $builder; $myFile = "testFile.txt"; $fh = fopen($myFile, 'w') or die("can't open file"); fwrite($fh, $builder); fclose($fh); ?>
Sorry for posting such a silly question i just couldn't figure it at first :/
Drongo
-
Hi Guys
I'm trying to create a little script that can read in a csv file and then write this as html to a text file.
I'm ok reading in the csv and generating the html table in browser but i'm at a loss as to how i can pass this newly create html table into a variable to pass to the filewrite.
What i want to acheive is a text file with the html code for the table.
echo "<table>\n"; $row = 0; $handle = fopen("testfile.csv", "r"); while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { if ($row == 0) { // this is the first line of the csv file // it usually contains titles of columns $num = count($data); echo "<thead>\n<tr>"; $row++; for ($c=0; $c < $num; $c++) { echo "<th>" . $data[$c] . "</th>"; } echo "</tr>\n</thead>\n\n<tbody>"; } else { // this handles the rest of the lines of the csv file $num = count($data); echo "<tr>"; $row++; for ($c=0; $c < $num; $c++) { echo "<td>" . $data[$c] . "</td>"; } echo "</tr>\n"; } } fclose($handle); echo "</tbody>\n</table>";
Still very new to php so any advice or help would be appreciated.
Thanks,
Drongo
-
Hi Mike
Well that did the trick!
I knew my thinking had gone astray somewhere. I didn't realise returning in a loop ended the loop.
My unenlightened logic thought that if it found an empty instance then it would return false and the break would stop the loop. Lesson learned.
Your code worked a treat
Thank you very much!
Drongo
The problem is you are returning true in your foreach loop. What happens is you test if something is empty. If its not you return true. What you want to do is test if something is empty and return false. then at the end of your foreach loop you can safely return true (because if you needed to return false, you would have already)
something like
function filters() { $this->validated = filter_input_array(INPUT_POST, $this->validation_options); foreach($this->validated as $key => $value) { if (empty($value)) { return false; //break; this is unecessary and doesnt even happen. if we return then the loop is automatically exited } } return true;//we checked everything. we didnt return false yet so return true }
EDIT: formatted the code i posted nicely
-
Hi Guys
I'm a noobie to this...still.
I'm starting to get into oop and I've tried to right a simple validation class.
The code I've created (assuming it's right) takes the POST array, runs a validation array against it and then iterates through the validation array to see if there are any empty values. My thought was is there's an empty value it should return false, stop the itterating through the array and thereby i'll know something isn't validated and i can execute some code (at the moment it just echos either valid or invalid)
I think i have gone wrong on the foreach part though because if the first array element is ok then it just displays that everything is valid - even if the other array elements are empty. I think maybe the "break" statement isn't doing what i think it should and stopping the loop. But i may be totally wrong.
Can anyone tell me where i'm going wrong please and suggest a better method along the lines of what i have created.
Many thanks,
Drongo - noobie phper :/
class registration { // Validatation options array public $validation_options = array( 'login' =>array('filter'=>FILTER_VALIDATE_EMAIL), 'password' =>array('filter'=>FILTER_VALIDATE_STRING), 'age' =>array('filter'=>FILTER_VALIDATE_INT) ); // Filter user input and direct accordingly function filters() { $this->validated = filter_input_array(INPUT_POST, $this->validation_options ); foreach($this->validated as $key => $value) { if (empty($value)) { return false; break; } else { return true; } } } function activate() { $this->filters(); if ($this->filters() == false) { echo "Not valid sorry"; } elseif ($this->filters() == true) { echo "all valid my son"; } } } $reg = new registration(); //$db->filters(); $reg->activate(); ?>
-
Well after an hour of scratching my head I got it to work. Thought I'd post it here to help any others in the noob boat
I think i need to seriously bone up on my jquery...
<script> $(function() { $( "#selectable" ).selectable({ stop: function() { $("#selectable li").click(function() { var tester = $(this).attr("value"); $("#content").html(tester); }); } }); }); </script> </head> <body> <div class="demo"> <ol id="selectable"> <li class="ui-state-default" value="100">1</li> <li class="ui-state-default" value="200">2</li> <li class="ui-state-default" value="300">3</li> <li class="ui-state-default" value="400">4</li> <li class="ui-state-default">5</li> <li class="ui-state-default">6</li> <li class="ui-state-default">7</li> <li class="ui-state-default">8</li> <li class="ui-state-default">9</li> <li class="ui-state-default">10</li> <li class="ui-state-default">11</li> <li class="ui-state-default">12</li> </ol> </div><!-- End demo -->
-
Hi Guys
I'm quite new to jquery ui and it's posing something of a headache to follow the demos :/
I'm trying to use the selectable grid (http://jqueryui.com/demos/selectable/#display-grid) and my desire is to pass a different value to a variable based on the item clicked. I'm then going to post that value to my php script.
I've worked out the latter part which was pretty straight forward. But i can't work out how to retrieve a value from clicking on the grid :/
Anyone able to help?
The code i'm working with is:
<script> $(function() { $( "#selectable" ).selectable(); }); </script> </head> <body> <div class="demo"> <ol id="selectable"> <li class="ui-state-default">1</li> <li class="ui-state-default">2</li> <li class="ui-state-default">3</li> <li class="ui-state-default">4</li> <li class="ui-state-default">5</li> <li class="ui-state-default">6</li> <li class="ui-state-default">7</li> <li class="ui-state-default">8</li> <li class="ui-state-default">9</li> <li class="ui-state-default">10</li> <li class="ui-state-default">11</li> <li class="ui-state-default">12</li> </ol> </div><!-- End demo -->
-
Hi Guys
I'm trying to make a simple Jquery animation but IE7 is giving me some display issues.
As you can see from the code below I simply have a containing div with overflow set to hidden. Within this is a large div containing two videos. When the button is clicked it simply animates the inner div left and right by adjust the margin, which displays either one of the videos.
The issue is that the animation works flawlessly in firefox but in IE7 when the animation is taking place the videos momentarily spills outside of the containing div and flickers in and out of view outside of the margin of the container. I'm a bit of a loss to explain why this is happening or how to correct it as jquery is somethnig i only use very seldom. So if someone could offer some advice to correct this it would be appreciated.
Thanks
Drongo
<html> <head> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> $(document).ready(function(){ $(".btn1").click(function(){ $("#moving_container").animate({marginLeft:"-300px"}); }); $(".btn2").click(function(){ $("#moving_container").animate({marginLeft:"0px"}); }); }); </script> </head> <body> <div style="width: 500px; height: 500px; border: 1px solid #000; overflow: hidden"> <!-- containing div --> <div id="moving_container" style="width: 1000px; height: 500px; border: 1px solid #000; margin-top: 100px;"> <!-- Large inner div --> <div style="width: 400px; height 300px;border: 1px solid #000; float: left;"> <!--video 1 div --> <iframe width="400" height="300" src="http://www.youtube.com/embed/4TpUQD2W_Ps?rel=0" frameborder="0" allowfullscreen></iframe> </div> <div style="width: 400px; height 300px;border: 1px solid #000;float: left;"> <!--video 2 div --> <iframe width="400" height="300" src="http://www.youtube.com/embed/4TpUQD2W_Ps?rel=0" frameborder="0" allowfullscreen></iframe> </div> </div> </div> <button class="btn1">Animate</button> <button class="btn2">Reset</button> </body> </html>
-
ooooooh...that makes a lot more sense! Just tried it with a longer string enclosing the tags and it works. TY
-
Hi Guys
Simple question. Can anyone tell me why this doesn't work please?
$test = "<HEELOOOO"; $test2 = filter_var("$test", FILTER_SANITIZE_STRING); echo $test2;
When I run this get I get nothing echoed back, not even in the source. So can the filter function not be used like this? I thought it would encode the special character and return it but I must be missing something simple here!
Thanks,
Drongo
-
Thanks David
I changed it back to the original as when i checked the source i realised nothing was happening when $name as the parameter and now you've pointed out the logic i can see why. Wrapping your head around the logical way the system deals with input is starting to click into place - slowly!
Thanks for the help!
Drongo_III - At some point someone suggested changing your method to this:
function check_input($name) { $data = trim($name); $data = stripslashes($name); $data = htmlspecialchars($name); return $name; }
If you take a close look at it, that method DOES NOTHING. It returns EXACTLY WHAT WAS PASSED IN. All of the operations in it are performed against $name and assigned to $data, but $name is returned UNMODIFIED.
Make sure you fix this method. Your original method was fine - I don't know why it was suggested to change the parameter name from $data to $name, but you either need to change all of the $name variables to $data or change all of the $data variables to $name.
-
Thanks JC! That helps a lot.
Well I think the case of the phantom validator is solved. I shall have Watson chronicle this in my memoires
Right onwards and upwards.
Thanks chaps!
Not a n00b mistake at all, it catches all of us from time to time. Sometimes staring at the monitor for to long, just gets to ya.
1.) Yes, the function is fine, but I would add mysql_real_escape_string() to the variable, if I was inserting to a mysql database.
2.) Yes, perfectly secure. Although it is less coding to run it straight through.
JS/Jquery while loop crashing browser - why?
in Javascript Help
Posted
Hi Guys
Trying to write a while loop to do validate a form. However when i came to testnig out a simple while loop it keeps crashing the browser and i'm not sure why. When i say 'crashes' the browser just endless appears to be loading and i can't refresh the page. Any ideas what is wrong with the following?
Any help is greatly apprecaited!
Drongo