Jump to content

et4891

Members
  • Posts

    74
  • Joined

  • Last visited

Everything posted by et4891

  1. 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?
  2. 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.
  3. 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); }); });
  4. 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.
  5. 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.
  6. 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?
  7. nevermind I was so stupid I should have used password all the way instead of using hash
  8. I have the following code just to insert a username and hashed password into the database but somehow I am getting this error and I couldn't find out where I am doing it wrong...can someone please give me a hand? I tried it in two ways and both errors... the first few lines are just connecting database which worked fine and a password.php so I can use password_hash() with my php version $hash = password_hash('xx', PASSWORD_BCRYPT, array('cost' => 10)); $username = 'xx'; $insertQuery = $db->prepare(" INSERT INTO et_todo (username, password) VALUES (:username, :hash) "); $insertQuery->execute(array( 'username' => $username, 'password' => $hash )); also tried $hash = password_hash('xx', PASSWORD_BCRYPT, array('cost' => 10)); $insertQuery = $db->prepare(" INSERT INTO et_todo (username, password) VALUES ('xx', :hash) "); $insertQuery->execute(array( 'username' => 'xx', 'password' => $hash ));
  9. I know that usually when we concatenante in PHP we use the period . to concatenate but I have been watching a few videos and they seems to use a comma , instead of . I didn't know about the comma before and if I didn't hear it wrong the video says both would work just depend on the way you work. So I tried using comma for testing such as echo '<pre>' , print_r($var) , '</pre>'; which works fine but when I use it in a function for fun such as function dd($var){ return '<pre>' , print_r($var) , '</pre>'; } this gives me errors about the comma but if I use period as concatenate the page would not return as html tag <pre> I know that I can just use var_dump and I tried searching things like difference between , and . in php or something similiar I couldn't find a page to explain the major difference. Can someone give me a hand? Sorry if this question is too stupid though.
  10. phonegap Do something like show all the contents in the filesystem which worked but if I want they all have links to them so if there's an image, I can click on it or if there's a text or if it's a directory...something like that...
  11. I have such list but with lists all contents in a directory but I want to create a link to also if you click into the file it'll read the file if it's a directory then it'll go into the directory.. e.g. the list is a (folder) b (folder) c (folder) d (folder) e (folder) f (folder) asdf.txt asdf.html asdf.ini and if I click on folder a then it'll go into the a directory if I click on asdf.txt then it'll show what's in the txt. I have the following code to create all the contents but not sure how to implement links into all directories and files for(var I in entries) { // creates li and /li var li = document.createElement('li'); //NOT SURE IF THIS IS RIGHT WAY TO START a.setAttribute('href', entries[I].name); //BUT NO IDEA WHAT AND WHERE I SHOULD PUT // creates the name of the contents li.appendChild(document.createTextNode(entries[I].name)); ul.appendChild(li); }
  12. *Sorry if I posted in the wrong forum, please let me know if I am* I have a piechart with three inputs one submit button. I can input whatever angle into the three inputs and the piechart will draw with a .js I found online. but I found there's a slight problem which is the second time I input a value it just overlaps the previous piechart so if the second time submitting the angles and the angle values are smaller than the original one then you won't be able to see it..I will attach an image to explain it more clearly. <canvas id="piechart1"></canvas> <script type="text/javascript" > $(function() { $("#submitBtn").click(function() { var input1 = $("#angle1").val(); if($("#angle1").val()=='') input1=""; var input2 = $("#angle2").val(); if($("#angle2").val()=='') input2=""; var input3 = $("#angle3").val(); if($("#angle3").val()=='') input3=""; piechart("piechart1", ["cyan", "yellow", "green"], [input1, input2, input3]); }); }); </script> <form action="" method="post"> <label>Angle 1</label> <label>Angle 2</label> <label>Angle 3</label> <br> <input name="" id="angle1" value="" type="number"> <input name="" id="angle2" value="" type="number"> <input name="" id="angle3" value="" type="number"> <input type="button" id="submitBtn" value="submit"> </form> Can someone give me a hand with this? Thanks a lot~!
  13. I'm wondering if anyone know if there's a good tutorial for new people to laravel and teaches you how to create a user/password login page? I used to watch tutorial of laravel 3.1 in tutsplus.com a 6 hours tutorials and got me interested with laravel and then 4 came out which I know added lots functions which makes things even more easier than before and I'm thinking of learning how to make a user/password login/sign up page. Any recommendation where I can get find tutorials like that? Because with videos instead of just words, I tried youtube and no luck for me
  14. ok I'm so stupid I should have echo those lines inside the foreach loop but then I believe my piechart scripts should be inside the foreach loop too but the thing is my script contains lots of html tags and so on and below is my codes <canvas id="piechart1" width="100" height="100"></canvas> <script src="<?php echo get_stylesheet_directory_uri().'/piechart.js'; ?>"></script> <script> var chartId = "piechart1"; var colours = ["#f00", "#0f0", "#00f"]; var angles = [<?php echo $line['comp2052_angle1'].','. $line['comp2052_angle2'].','. $line['comp2052_angle3']; ?>]; piechart(chartId, colours, angles); </script> how can I implement those codes into foreach easily instead of echo them out bit by bit?
  15. What I'm trying is I have a page which you can input 3 angel integers and submit. After you submit the data will be saved in database using json encode and another page to retrieve the data and make the angles to draw a pie chart. {"angle1":"60","angle2":"60","angle3":"90","submit":"Submit"} The above is what's saved into a row I used <?php $sql = "SELECT * FROM wp_options WHERE option_name LIKE 'angle%' ORDER BY option_name"; $options = $wpdb->get_results($sql); foreach ( $options as $option ) { echo '<p><b>'.$option->option_name.'</b> = ' .esc_attr($option->option_value).'</p>'.PHP_EOL; $line = json_decode($option->option_value, true); } echo '<span style="color:#f00;">'.'Angel 1 : '.$line['angle1'].'</span><br>'; echo '<span style="color:#0f0;">'.'Angel 2 : '.$line['angle2'].'</span><br>'; echo '<span style="color:#00f;">'.'Angel 3 : '.$line['angle3'].'</span><br>'; This prints out angel 1 : ## where ## is the angle entered and so on. I also made a simple 2d piechart which shows the angles. the problem I'm having is if I submit another 3 angles then my result only shows the MOST RECENT angles entered even if there are two or more in the database. For example in my database I can see {"angle1":"60","angle2":"60","angle3":"90","submit":"Submit"} {"angle1":"60","angle2":"60","angle3":"180","submit":"Submit"} {"angle1":"30","angle2":"60","angle3":"180","submit":"Submit"} but the result only prints 30 60 and 180 instead of printing all three. Anyone mind giving me a hand on how I can print all three data out or at least all three sets of the angles. I believe once I figured that out I can then print out all the piecharts with all the angles instead right now only the most recent angle and the piechart are printed. Thanks a lot people~
  16. so I should do something like below? $options = json_decode($wpdb->get_results($sql),true);
  17. I have three text box for people to enter as numbers and stores in json <?php add_option('angels_'.date("ymd-His"), json_encode($_POST)); ?> The data stored in the database looks like {"angle1":"60","angle2":"60","angle3":"90","submit":"Submit"} the above is also what I get what I called out the data from the database I used this code to call out the data <?php $sql = "SELECT * FROM wp_options WHERE option_name LIKE 'angels%' ORDER BY option_name"; $options = $wpdb->get_results($sql); foreach ( $options as $option ) { esc_attr($option->option_value).PHP_EOL; } $values = esc_attr($option->option_value); echo $values; ?> The output gives me {"angle1":"60","angle2":"60","angle3":"90","submit":"Submit"} if I only want to get the numbers 60/60/90 individually how can I do that?
  18. thanks a lot...omg such a simple step and my head couldn't get around to get it...*arg*
  19. I think I'm confusing myself again~!
  20. ah alright....damn how can I miss such obvious thing... but somehow I kept on trying and trying and still couldn't just echo the vote number
  21. Ch0cu3r> somehow this didn't work. This gives out error for undefined index:metallic $votes[ $vote['type'] ]++; the previous one works well though gives this Array ( [metallic] => 2 [pop] => 1 ) But I'm really sorry first time making array like this...so now I only want to print the number 2 I thought normally something like $votes[0] would echo the number and I tried something like $vote[0] or $vote['metallic'] might work but guess I'm wrong.... P.S. Thanks guys. Really sorry for all the trouble....thought this would be something fun for myself to do and learn.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.