Jump to content

et4891

Members
  • Posts

    74
  • Joined

  • Last visited

Recent Profile Visitors

3,105 profile views

et4891's Achievements

Member

Member (2/5)

0

Reputation

  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~!
×
×
  • 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.