Jump to content


  • Posts

  • Joined

  • Last visited

Everything posted by MrFish

  1. I have a client that loves the ajax/lightbox concept. Wants to use it on practically everything. I have several forms with many fields that I'm trying to make easier to submit with JQuery post. If you aren't familiar, JQuery post looks like this- $.post(url, {"key" : "value", "key2" : "value2"}, function(){}); And what I'm trying to do is loop through all of the inputs and build a string that I can submit easily like this. But I don't know how to take a string and turn it into this syntax. I don't really even understand this syntax since I only see it in objects and I've written objects a more old fashioned way I guess you can say. My code looks like this- window.QuickSubmit = function(formId, finish) { frm = document.getElementById(formId); loc = frm.getAttribute("action"); eles = frm.elements; str = ""; for(i = 0; i < eles.length; i++) { fld = eles[i]; tag = fld.tagName; key = fld.getAttribute("name"); if(key == null) continue; if(tag == "SELECT") { value = fld.options[fld.selectedIndex].value; if(value == null) value = fld.options[fld.selectedIndex].text; } else { value = fld.getAttribute("value"); } str += key + ":" + value + ","; } str = str.substr(0, str.length-1); var d; $.post(loc, eval("{" + str + "}"), d=finish); return d; } I've tried different methods. My most resent was to use eval but I get an error when doing that-Uncaught SyntaxError: Unexpected token :
  2. You should set the width of your elements to the exact width that you want them. Instead of 100% on a container div make it 978px to match your header.In your header make 3 separator divs. header-left, header-center, header-right. In the left put your image, in the center put your text, and in the right put your search box. Then use float: left; on these 3 divs and they will line up left-to-right. Right now your text is over your image.
  3. I like it. Simple and addicting. Buttons should probably use a touch up.
  4. You'll need to use javascript. When your mouse moves over the button you need to get that buttons contents. I do this by writing an attribute called "target". But it's not w3 compliant. Not sure if you mind this but it works with all browsers so I don't. <table id="menu"><tr><td target="topmovies">Best Movies</td><td target="worstmovies">Worst Movies</td></tr></table> The target points to a hidden div or table. Tables are more difficult to use and less flexible. But if you wan't to use tables I will use table examples. <div class="hidden"><table id="topmovies">...</table><table id="worstmovies">...</table></div> Write your hidden class like this- .hidden{visibility: hidden;height: 1px;width: 1px;overflow: hidden;position: absolute;top: 0px;left: 0px;z-index: 1000;} Then when you mouse over the cell with your mouse you should extract the table information and add it to a sub menu table. menu = document.getElementById("menu");buttons = menu.childNodes[0];for(i = 0; i < buttons.length; i++){button = buttons[i];button.onmouseover = function(){// get target -> extract information -> add to submenu -> position submenu -> show submenu}button.onmouseout = function(){// yah} Something like that. See if you can fill in the rest.
  5. Your site link takes me to a 404 page.
  6. MrFish

    center nav bar

    Are you using internet explorer?body{ text-align: center;}
  7. MrFish

    center nav bar

    test-align: center; is for everything inside that element. You can use margin: 0px auto; to center the ul element.
  8. It's possible if you save files as .php and let people access that file. But when you submit a form you call the information with $_POST["inputName"]; When you do that, all the information is a string value so it won't affect your php at all. I don't think anyone here is keeping secrets. htmlspecialchars will change any characters that could be printed and interpreted as html. " will become "& will become &< will become <etc. This website is hack proof.
  9. You could try using lists and css. I think that would be the easiest way. <style type='text/css'> ul { margin: 3px 0px 3px 10px; font-weight: 700; font-size: 14px; } ul li { margin-left: 5px; list-style-type: none; font-weight: 500; font-size: 12px; cursor: pointer; } ul li:hover { background-color: #eee; }</style><ul> Folder <li>item.htm</li> <li>item.php</li> <li>image.png</li> <ul> Sub Folder <li>item.js</li> </ul> <ul> Sub Folder <ul> Sub sub folder <li>item.css</li> <li>item.php</li> </ul> </ul></ul>
  10. For what you're trying to do I would recommend you instead print the images to a hidden div element with php and then use javascript to loop through the elements of that hidden div. <div class='hidden' id='imagesHolder'><img src=""><img src=""><img src=""></div> Then with javascript- imagesHolder = document.getElementById("imagesHolder");images = imagesHolder.childNodes;for(i = 0; i < images.length; i++){image = images[i];} Something like that. You would only want to use ajax if the content changes often. If you use ajax it will be unnecessarily slow for your visitors when they need to make a new http request every time they want to get another image.But to answer your question. If you are set on the ajax method then you can do something like this- <span id="imageIds" value="1,2,3"></span> window.currentImagePosition = 0;imageIds = document.getElementById("imageIds");val = imageIds.value;numIds = val.length;window.currentImagePosition++;if(window.currentImagePosition >= numIds) window.currentImagePosition = 0;imageId = imageIds[window.currentImagePosition]; Then send that image id using ajax to your php page that would return an image src that is related to the id.
  11. You error is saying copy is not working. And your $orig variable only works on image objects. $chunks = explode('.', $src); $ext = $chunks[count($chunks) - 1]; if ($ext == 'jpg' OR $ext == 'JPG') $orig = imagecreatefromjpeg($src); elseif ($ext == 'gif' OR $ext == 'GIF') $orig = imagecreatefromgif($src); elseif ($ext == 'png' OR $ext == 'PNG') $orig = imagecreatefrompng($src); copy requires 2 string parameters. The first parameter is the path to the file and the second is the destination path. So you'l wantcopy($src, $dst);
  12. Ok, I will try that. Thank you
  13. copy($orig, $dst); $orig is a php image object. It should be a path to your original file.
  14. I don't know if this is possible because when posting file information through a form it has to have special properties unlike simple string data. So is it possible to upload, say, and image file with ajax? Preferably with a JQuery example because it's so much simpler but I would be grateful for any example that worked.
  15. function imgshow(image){ document.getElementById('showcase').setAttribute("src", image); } This is correct. To use window.showcase you can put this anywhere in your code but for your purposes you should put it outside of functions. So at the start- <script>window.showcase = document.getElementById("showcase");function setsize(){ if (showcase && showcase.style){ showcase.style.height = '300px'; showcase.style.width = '400px'; } } But this won't work before showcase has been loaded. So you'l need to wait until the body is loaded because you use document.getElementById function init(){window.showcase = document.getElementById("showcase");}......<body onload="init()">...
  16. That's correct.Also, Math.random() generates a decimal between 0 and 1 (like 0.2248631827533245) which is why you have to multiply it by the maximum amount you are looking for +1. Just thought I should note that since it might be obvious.
  17. Your image won't show because element.src isn't a variable javascript knows while element.href is. Use element.setAttribute("src", image);.You can define variables outside of functions and it will be in the window scope. All of your javascript runs in an object called "window". You can think of this like a box that holds everything. Nothing is outside the box. You can create a global variable this way or like this- window.showcase- anywhere in your code to be sure that it is global.
  18. If you know mod rewrite that it can be done just the same. You aren't necessarily in a folder called asus but if that's the url then it's for your server to decide where it actually goes.RewriteRule ^(.*)$ desktop-pcs/$1.htmOr you could use php to further process the url for specific cases. Like if the url was /ipods then there wouldn't be a computer brand under ipods so you can send the query to a page that finds what the user is actually looking for.RewriteRule ^(.*)$ parsepage.php?page=$1In the php page you would determine what the user is looking for and redirect to the actual page. This process would occur without the user's browser actually visiting that middle-man page and would go directly to the page requested.
  19. This should be in the SQL section I believe.Also please post the relevant code that is causing this error.
  20. This works for me- window.oncontextmenu = function(){return false;}
  21. Give the form a name so you can execute it with javascript. Replace your submit button with a regular button and when you click the button check the inputs. If all checks out then you can submit the form in javascript using the form name. If it doesn't all check out then take whatever actions to informing the user of the problems.HTML <form name="myform" action="..." method="post">inputs ...<input type="button" onclick="checkMyForm()"/></form> Javascript function checkMyForm(){form = document.forms["myform"];if(conditions == true) form.submit();else{ //Show errors}
  22. You can learn most of it here on w3schools but google is a big help too when you know what you're looking for. When you start practising what you learn on w3schools it starts becoming hard grained into your memory. Like you never forget how to ride a bike I don't think I can forget any of these languages. To learn best, pick a website you want to build and just start building it. It's hard to read through everything and retain all that you learned. I tried that several time. And just keep going until you run into something you don't know how to do. Like- "hmm... How to a create a login with php?". Then you google that.HTML- Page structureCSS- Page stylingJavascript- Client side scriptingJQuery- Javascript library to make things faster/easierAjax- Client-Server communicationPHP- Server side scriptingMySQ - Databases
  23. I don't have a degree in anything and I'm only fresh out of highschool so I will give you fair warning that my advice is limited to what I've heard from developers here in the US.The most important thing (so I've been told) is that you have experience. What you read in books won't automatically make you a great programmer. While you learn make as many programs/websites as you can and build a portfolio. There is nothing like experience and that's what (so I've been told) employers look for. Especially in what I assume to be an employer's market like India. Where an employer has so many developers applying for the position that the one that has the most experience and can demonstrate his/her ability best will get the job.If you want to program then India's equivalent to Computer Science is what you want a degree in. Computer Science doesn't necessarily teach you any specific language but teaches theory on the best way to do it in any language. With a CS degree you will never run out of work. At least until a program is written that writes programs. Then god help us.There's my two cents.
  24. Using css you can automatically position it horizontally. <div style="width: auto; margin: 0px; auto;">Some Text</div> But unfortunately it doesn't have an automatic vertical positioning system. So you would need javascript. Something like this- function positionElement(ele){ w = ele.offsetWidth; h = ele.offsetHeight; if(window.innerHeight) { wh = window.innerHeight; ww = window.innerWidth; } else { wh = document.documentElement.offsetHeight; ww = document.documentElement.offsetWidth; } centerW = ww/2; centerH = wh/2; centerEW = w/2; centerEH = h/2; newX = centerW-centerEW; newY = centerH-centerEH; ele.style.position = "fixed"; ele.style.top = newY; ele.style.left = newX;}window.onresize = function(){ ele = document.getElementById("elementId"); window.positionElement(ele);}ele = document.getElementById("elementId");window.positionElement(ele); Tested and working. Be sure to read through it and get an understanding about what's going on. I just get the width and height of the supplied element, the width and height of the visible area of the window. Do a little math to find where the elements x/y should be to make it center. And I set 3 properties of css with javascript-position: fixed;top: [yLocation];left: [xLocation];
  25. MrFish


    The reason you would choose unique would be so that the script would know when it's found the result it looking for as soon as it's made a match. Unique means that every entry in that column is 100% unique from any other.This error means you have a duplicate entry.
  • Create New...