
et4891
Members-
Posts
74 -
Joined
-
Last visited
Everything posted by et4891
-
ah! ok so it's pretty much making them all have the another class that's the same will give me the chance to use $(this) which means I didn't even need to combine just one code with $(this) would then work. that's the idea for the fist choice right?
-
why is my script keep repeating multiple times? jquery
et4891 replied to et4891's topic in Javascript Help
nope, after you asked, I searched the script for colorHolder again to make sure. But in the whole script the variable colorHolder only showed up 3 times which is the same as the script I posted. first is using it to declare as a global variable, 2nd time is to assign the class of an element to it 3rd is to split the variable since the variable will be assigned with two classes. -
oh no! sryz didn't even realize that....my bad..weird I can't seem to edit my post... let me post the scripts here var colorHolder = null; //used to store the location where color is picked $('.color-side-a .number-of-color-field > div').on('click', function(){ colorHolder = $(this).attr('class'); $('.colorSelectBox').css({"left": "100px", "top": "570px"}).toggle(); $('div.black').add('div.yellow').on('click', function(){ var colorAttr = $(this).attr('value'); var splitClass = colorHolder.split(" "); $('.color-side-a').closest('div').find('.'+splitClass[0] + '.'+splitClass[1]).css({"background": colorAttr}).attr('value', colorAttr); }); }); $('.color-side-b .number-of-color-field > div').on('click', function(){ colorHolder = $(this).attr('class'); $('.colorSelectBox').css({"left": "100px", "top": "570px"}).toggle(); $('div.black').add('div.yellow').on('click', function(){ var colorAttr = $(this).attr('value'); var splitClass = colorHolder.split(" "); $('.color-side-b').closest('div').find('.'+splitClass[0] + '.'+splitClass[1]).css({"background": colorAttr}).attr('value', colorAttr); }); });
-
why is my script keep repeating multiple times? jquery
et4891 replied to et4891's topic in Javascript Help
adding up....it's like going 1,2,3 then 3, 6 something like this randomly. well works well if I didn't use the console.log I wouldn't even realize it's repeating so many times because it works. -
I have divs which can be clicked and then another div will pop out with few colors for users to choose. After choosing the colors in the div that pop out the div that is clicked will change into that background. I used class to determain which div is clicked. function works fine but I realized when I try console.log the class I used as global to findout which div to change the background. the console.log keeps adding up also multiplying too. Can I have a pair of eye to see where it's adding things up? var colorHolder = null; //used to store the location where color is picked function colorFieldPicker(onClickSide, xValInput, yValInput,side){ onClickSide.on('click', function(event){ colorHolder = $(this).attr('class'); var yVal = (event.pageY - yValInput) + "px"; var xVal = (event.pageX / xValInput) + "px"; $('.colorSelectBox').css({"left": xVal, "top": yVal}).toggle(); colorPickerOnClick(side); }); } function colorPickerOnClick(side){ $('div.black').add('div.yellow').on('click', function(){ var colorAttr = $(this).attr('value'); var splitClass = colorHolder.split(" "); side.closest('div').find('.'+splitClass[0] + '.'+splitClass[1]).css({"background": colorAttr}).attr('value', colorAttr); console.log(colorHolder); //this is where it's displaying in console that it'll keep on adding up. $('.colorSelectBox').css({"display": "none"}); }); } Thanks everyone in advance.
-
I have this html to let people select how how many color div wants to have from 1-3 <div class="color-side-a"> <p class="sideABCD-header">Side A</p> <div class="dimension-width"> <p class="dimension-WHC">Colors</p> <select name="number-of-colors" class="number-of-colors"> <option value="" group="1">Select A Number</option> <option value="1" group="1">1</option> <option value="2" group="1">2</option> <option value="3" group="1">3</option> </select> <div class="number-of-color-field"> <div name="color1" class="sideA color1"></div> <div name="color2" class="sideA color2"></div> <div name="color3" class="sideA color3"></div> </div> </div> </div><!-- end side A --> <div class="color-side-b"> <p class="sideABCD-header">Side B</p> <div class="dimension-width"> <p class="dimension-WHC">Colors</p> <select name="number-of-colors" class="number-of-colors"> <option value="" group="colors">Select A Number</option> <option value="1" group="colors">1</option> <option value="2" group="colors">2</option> <option value="3" group="colors">3</option> </select> <div class="number-of-color-field"> <div name="color1" class="sideB color1"></div> <div name="color2" class="sideB color2"></div> <div name="color3" class="sideB color3"></div> </div> </div> </div><!-- end side B --> I have this jquery to show /hide depend on the value chosen which is really just depend on value then show() /hide() the other divs which I didn't show since it's just simple something like value == 1, color1.show() color2.hide() and so on I have this function which then lets people pick the color they wanted in the selectColorBox div I know this code is duplicating but I tried a few ways and not sure how I can combine them in order to reuse most of the codes and if I have side C D E F G I wouldn't need to just copy and paste my codes var colorHolder = null; //used to store the location where color is picked <div class="color-side-a"> <p class="sideABCD-header">Side A</p> <div class="dimension-width"> <p class="dimension-WHC">Colors</p> <select name="number-of-colors" class="number-of-colors"> <option value="" group="1">Select A Number</option> <option value="1" group="1">1</option> <option value="2" group="1">2</option> <option value="3" group="1">3</option> </select> <div class="number-of-color-field"> <div name="color1" class="sideA color1"></div> <div name="color2" class="sideA color2"></div> <div name="color3" class="sideA color3"></div> </div> </div> </div><!-- end side A --> <div class="color-side-b"> <p class="sideABCD-header">Side B</p> <div class="dimension-width"> <p class="dimension-WHC">Colors</p> <select name="number-of-colors" class="number-of-colors"> <option value="" group="colors">Select A Number</option> <option value="1" group="colors">1</option> <option value="2" group="colors">2</option> <option value="3" group="colors">3</option> </select> <div class="number-of-color-field"> <div name="color1" class="sideB color1"></div> <div name="color2" class="sideB color2"></div> <div name="color3" class="sideB color3"></div> </div> </div> </div><!-- end side B --> this is my simple div box for user to pick colors <div class="colorSelectBox"> <div>Special</div> <div> <div class="pink" value="pink"></div> <div class="black" value="black"></div> <div class="yellow" value="yellow"></div> </div> <div class="clear"></div> <div>Original</div> <div> <div class="red"></div> <div class="blue"></div> <div class="grey"></div> <div class="green"></div> <div class="white"></div> </div> </div> how can I combine those two duplicated jquery into one function that I can further use more later if needed?
-
thanks a lot
-
not a specific sub directory...I want to find all images in all sub directory and then make it thumbnail.
-
I found a way to do what I want but still missing something here I couldn't figure out... this is what I have at the moment... <?php function dirToArray($dir) { $contents = array(); foreach (scandir($dir) as $node) { if ($node == '.' || $node == '..') continue; if (is_dir($dir . '/' . $node)) { $contents[$node] = dirToArray($dir . '/' . $node); } else { $contents[] = $node; } } return $contents; } $c=(""); $r = dirToArray('./images'); foreach($r as $a) { foreach($a as $b) { if(substr($b, -3) == "png") { $c.="<img src='/images/" . $b . ".png'>"; } } } echo $c; ?> but when I look at the source code....I see... <img src='/images/Screenshot_2013-06-02-19-41-36.png'> but I need it to be <img src='/images/(directory)/Screenshot_2013-06-02-19-41-36.png'> somehow I can't think how to implement the (directory) in...
-
I'm actually thinking of using jquery lightbox to apply to all my images but I figured with jquery lightbox I should at least make a page with all thumbnail images. So I'm trying to think of a way to easily bring out all the images in the folder+subfolders, but somehow I'm searching through sites/goolging most of them only talk about scandir and glob. I tried something like... foreach (glob("*.png") as $filename) { echo "$filename size " . filesize($filename) . "\n"; } but glob still doesn't go INTO sub directories same as for scandir... I can do the same code few times to check each sub directories but it'll be a annoying to do so... $image_files = scandir("./images/"); I thought of doing the code above and sub a variable into ./images/variable within a loop or something but somehow I just can't get outside the box and get it to work... anyone able to give me a hint or give me a hand? Thanks in advance...
-
I installed mysql server 5.1 and no error happens during the installation so I assume everything is fine but when I'm learning and trying to use php and to connect through mysql and there is this error message saying Fatal error: Call to undefined function mysqli_connect() in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\books.php on line 3 My codes are here <?php $db = mysqli_connect("localhost", "root", "3308") or die(mysqli_connect_error()); mysqli_select_db($db, "booksdb") or die(mysqli_error($db)); mysqli_query($db, "CREATE TABLE books( id INT PRIMARY KEY NOT NULL AUTO_INCREMENT, title VARCHAR(64) NOT NULL)") or die(mysqli_error($db)); mysqli_query($db, "INSERT INTO books(id, title) VALUES(NULL, 'the nose')") or die(mysqli_error()); mysqli_query($db, "INSERT INTO books(id, title) VALUES(NULL, 'the overcoat')") or die(mysqli_error()); mysqli_query($db, "INSERT INTO books(id, title) VALUES(NULL, 'war and peace')") or die(mysqli_error()); $result = mysqli_query($db, "SELECT id, title FROM books") or die(mysqli_error()); while($record = mysqli_fetch_assoc($result)){ echo $record['id']; echo " "; echo $record['title']; echo "<hr/>"; } ?> in my php.ini file I did uncomment both extension=php_mysql.dll extension=php_mysqli.dll and of course restarted apache. Also restarted the who machine too but that error message keeps on coming up and I have no idea how to fix it. I searched a few forums and they all asked to make sure the extension is uncommented which they are.