Jump to content

KevinM1

Moderators
  • Posts

    5,222
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by KevinM1

  1. 1. What exactly are you trying to do? 2. What isn't working? 3. Why aren't you using CSS for image rollovers?
  2. Hrmm, is there a way I can accomplish what i'm looking to do? I've never played with Wordpress, but I'm sure there is. You'd just need to connect to the other db, pull the correct results, and post them. I can't tell you how to do that without seeing how Wordpress does it.
  3. Include isn't an assignable function. That is, you can try to stuff the contents retrieved from it in a variable. Instead, include and its related functions (include_once, require, and require_once) simply dump all of the included file's contents into the script at that point.
  4. EDIT: haku, would something simple like: window.opener.el.value = 'something'; work? I'm just wondering if a child window has knowledge of its parent's variables.
  5. Hmm...yeah, you're in a pretty tight corner. Unfortunately, there's no easy, 'clean' solution. The easiest thing I can think of would be to pass in the target element, which you already do, then, for the Mozilla side of things, attach that element's id to the pop-up's url as a query string. So, something like: /* IF MOZILLA */ else { window.open('link-popup.php?sender=' + el.id, 'name', 'height=280,width=550,toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,modal=yes'); } In the pop-up, you can grab a hold of the query string value by writing a function like (note: comes from a 3rd party, so I haven't tested it...): function getQuerystring(key, default_) { if (default_==null) default_=""; key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); var regex = new RegExp("[\\?&]"+key+"=([^&#]*)"); var qs = regex.exec(window.location.href); if(qs == null) return default_; else return qs[1]; } So, with that in the pop-up, you could modify your updateEditorAMozilla() function like so: /* FUNCTION CALLED FROM POPUP WINDOW TO SET AN A HREF TAG IN EDITOR WHEN USING MOZILLA */ function updateEditorAMozilla(fldVal) { var tagBeginning = fldVal; var tagEnding = "</a>"; var target = getQuerystring('sender'); var el = window.opener.document.getElementById(target); if (el.setSelectionRange) { el.value = el.value.substring(0,el.selectionStart) + tagBeginning + el.value.substring(el.selectionStart,el.selectionEnd) + tagEnding + el.value.substring(el.selectionEnd,el.value.length) } el.focus(); } You'd have to move the Mozilla function into the pop-up, though there's probably a way to keep it in the main page with a little work.
  6. Hmm... can you show me all the code of your pop-up window?
  7. So, wait...why can't you simply pass along the element to the function you need? You already have a handle on the proper element - it's the argument you pass into the function. What's stopping you from passing that into the pop-up window along with the text you're modifying?
  8. How are you calling this function? I have an idea of what you're trying to do, but would like more info just to be sure.
  9. Yup. Flash. I believe there are free editors around, but I'm not too knowledgeable in that area. And, given their free, not-from-Adobe nature, their quality may be suspect as well. How would any of us know? What you're asking depends on your abilities, commitment, and interest. Your best bet is to go to the local bookstore and peruse a book on the subject. That way you can get a decent idea of the cost of learning it (both time AND money), as well as whether or not Flash is for you, before jumping in.
  10. Also: 1. Put your form inputs' names within quotes in the HTML (i.e.: <input name="Name"> ). 2. Don't put a space between an array name and the key you're trying to access. In other words, do this: $name = $_REQUEST["Name:"]; 3. Use the right superglobal array instead of $_REQUEST. Since you're passing the data in via POST, use $_POST. 4. Are you certain that you can mail things out successfully? Have you tried writing a small test script to see if the mail() function is working at all?
  11. 1. Are you sure you want to create a new table in this code? Is this page going to be viewed more than once by the same user(s)? If so, you should create the table manually, through whatever database management system you have access to (phpMyAdmin?), and only let the PHP script insert/update data. 2. Where do $websites and $destination come from?
  12. Well, first, to get a technicality (and pet peeve of mine) out of the way, $_GET is not a function. It's a superglobal array filled with values passed into a script via query string. Big difference. Anyhoo, to get to your problem, you should know what incoming $_GET values are legit. In other words, you should know that, like you say, news only has 13 items. Knowing that, you simply need to test if the incoming value is good (in this case, less than or equal to 13). If so, they proceed normally. If not, write the error message and/or redirect back to the homepage. In pseudo-code, something like: if($_GET['news'] <= 13) { /* proceed to the news item */ } else { /* echo error, and give link to redirect back to home */ echo "The page you're looking for doesn't exist. Please go back to <a href=\"index.php\">home</a> and try again. If the problem persists, contact our webmaster."; }
  13. Something like the following should work: $count = 0; $table = "<table><tr>"; while($row = mysqli_fetch_assoc($result)) { if(($count % 4) == 0) { $table .= "</tr><tr>"; } if($row['image'] == 'blank') { $row['image'] = "image/achievement_locked.png"; } $table .= "<td><img src=\"{$row['image']}\" alt=\"{$row['alt_text']}\" /></td>"; ++$count; } $table .= "</tr></table>"; echo $table;
  14. It's a syntax issue. Since the inputs use array notation, you can't reference them quite the way you're attempting to. Instead, try: document.forms['form'].elements['data[name]'].value; See also: http://www.javascripttoolbox.com/bestpractices/#squarebracket
  15. I loved Ubuntu during the short stint I had with it a couple years ago. I don't remember which editor I used, though. It did have code highlighting, which was nice.
  16. Since when has Windows been more secure than OSX? When has IE ever been considered more secure than FireFox or Opera? I like Macs. I really do. I used an iBook in college to take class notes and write simple web pages, and it was simple to use and stable as hell. But, in regards to web development, they're not any more capable than a Windows machine. Or a *nix machine, if you're comfortable using The GIMP as your graphics editor.
  17. Hmm..doesn't emacs or vim provide highlighting? In Windows-land, I use Notepad++. It has text highlighting and indent matching (I'd insert the image directly, but it breaks h-scroll): www.nightslyr.com/notepad.jpg
  18. Maybe I'm looking at this wrong, but isn't this a clear case of where delegation should be used? It seems like the most obvious solution to me. I mean, MM wants a User to own (contain) Photos associated with them. This User, logically, should be able to modify their own Photos. Why not just have an array of Photos as a property of the User class, then a series of methods that delegate to the Photo's methods? Something like: class User { private $photos = array(); . . . public function addCaption($key, $caption) { $this->photos[$key]->addCaption($caption); } } class Photo { private $caption; . . . public function addCaption($caption) { $this->caption = $caption; } } $Bob = new User(); . . . $Bob->addCaption("vacation", "My summer vacation"); //remember, array keys (in this case, "vacation") can be strings
  19. The code I gave you should work. I made a small test case that uses the same method of appending 'i' to the id of a group of elements, and it works correctly: <html> <head> <title>JavaScript loop test</title> <script type="text/javascript"> window.onload = function() { for(var i = 1; i < 4; i++) { var divObj = document.getElementById("div" + i); divObj.onmouseover = function() { this.style["border"] = "1px solid black"; } divObj.onmouseout = function() { this.style["border"] = ""; } } } </script> </head> <body> <div id="div1"> This is div1 </div> <div id="div2"> This is div2 </div> <div id="div3"> This is div3 </div> </body> </html>
  20. Try: function start() { for(var i = 1; i < 6; i++) { var videoObj = document.getElementById("video" + i); var overlayObj = document.getElementById("overlay" + i); videoObj.onmouseover = function() { overlayObj.style.display = 'inline'; } overlayObj.onmouseout = function() { this.style.display = 'none'; } } }
  21. I'm not sure if this really belongs here or if it's more suitable for the design/layout sub-section, so feel free to move it if I put it in the wrong place. I've written a simple e-commerce checkout script. The user's shopping cart is just persistant session info, as I didn't want to create a database table for every user. Upon checkout, the user is supposed to enter in their personal and credit card info, which, upon submission, will be e-mailed to our sales guy so he can put in the order with our distributor (not the most elegant system, I know, but it seems like it'll work). My biggest problem, right now, is the sheer bulk of the checkout script. I've tested it, and it works, but it's very long and no doubt heavy handed. Originally, I created a simple sticky form which worked well. The only problem is that my boss wanted it only to be sticky if someone didn't input their info correctly. If they did enter their info in correctly, then he wanted the form to disappear with a little message saying that the order was processed. I've managed to get all of that functionality into the script, but like I said, it's very bulky right now. Is there anything I can do to make it more manageable and readable? I'd like to keep everything in one script, if possible. My code: <?php #checkout.php session_start(); ob_start(); include('../php_config/config.php'); include('../templates/sub_header.inc'); if(!isset($_SERVER['HTTPS']) || strtolower($_SERVER['HTTPS'] != 'on')){ header("Location: https://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); } $errMessage = NULL; $mailMessage = NULL; if(isset($_POST['continue'])){ $_SESSION['ip'] = urlencode(serialize($ip)); $_SESSION['myCart'] = urlencode(serialize($myCart)); header("Location: http://www.thinkingmachinestore.com/"); exit(); } if(isset($_POST['back'])){ $_SESSION['ip'] = urlencode(serialize($ip)); $_SESSION['myCart'] = urlencode(serialize($myCart)); header("Location: " . $_SERVER['PHP_SELF']); exit(); } if(isset($_POST['submit'])){ if(!empty($_POST['name']) && preg_match("/^[a-zA-Z]+([ a-zA-Z-]+)*$/i", $_POST['name'])){ $name = $_POST['name']; $n = TRUE; } else{ $errMessage .= "Please enter your name!<br />\n"; } if(!empty($_POST['address1']) && preg_match("/^[0-9a-zA-Z\.\-\ ]+$/i", $_POST['address1'])){ $address1 = $_POST['address1']; $a1 = TRUE; } else{ $errMessage .= "Please enter your address!<br />\n"; } if(!empty($_POST['address2']) && preg_match("/^[0-9a-zA-Z\.\-\ ]+$/i", $_POST['address2'])){ $address2 = $_POST['address2']; } else{ $address2 = ''; } if(!empty($_POST['city']) && preg_match("/^[a-zA-Z\.\-\ ]+$/i", $_POST['city'])){ $city = $_POST['city']; $c = TRUE; } else{ $errMessage .= "Please enter your city!<br />\n"; } if(!empty($_POST['state']) && preg_match("/^[a-zA-Z]{2}$/i", $_POST['state'])){ $state = $_POST['state']; $s = TRUE; } else{ $errMessage .= "Please enter your state!<br />\n"; } if(!empty($_POST['zipcode']) && preg_match("/^[0-9]{5}(\-[0-9]{4})?$/i", $_POST['zipcode'])){ $zipcode = $_POST['zipcode']; $z = TRUE; } else{ $errMessage .= "Please enter your zipcode!<br />\n"; } if(!empty($_POST['home_num']) && preg_match("/^[0-9]{10}$/i", $_POST['home_num'])){ $homeNum = $_POST['home_num']; $hn = TRUE; } else{ $errMessage .= "Please enter your home telephone number!<br />\n"; } if(!empty($_POST['email']) && preg_match("/^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/i", $_POST['email'])){ $email = $_POST['email']; $e = TRUE; } else{ $errMessage .= "Please enter your e-mail address!<br />\n"; } if(isset($_POST['card_name'])){ $cardName = $_POST['card_name']; $cn = TRUE; } else{ $errMessage .= "Please select a credit card!<br />\n"; } if(!empty($_POST['card_num']) && preg_match("/^[0-9]{16}$/i", $_POST['card_num'])){ $cardNum = $_POST['card_num']; $cNum = TRUE; } else{ $errMessage .= "Please enter your credit card number!<br />\n"; } if(!empty($_POST['CID']) && preg_match("/^[0-9]{3,4}$/i", $_POST['CID'])){ $cid = $_POST['CID']; $cidCheck = TRUE; } else{ $errMessage .= "Please enter your credit card's CID!<br />\n"; } if(!empty($_POST['bank_num']) && preg_match("/^[0-9]{10,11}$/i", $_POST['bank_num'])){ $bankNum = $_POST['bank_num']; $bn = TRUE; } else{ $errMessage .= "Please enter your credit card's telephone number!<br />\n"; } if($n && $a1 && $c && $s && $z && $hn && $e && $cn && $cNum && cidCheck && $bn){ if($address2){ $cartInfo = $myCart -> emailMessage(); $mailMessage .= "<html><head><title>Order Confirmation</title><body>$name<br />\n$address1<br />\n$address2<br />\n$city, $state $zipcode<br />\nHome Phone Number: $homeNum<br />\nE-mail Address: $email<br />\n<br />\nCredit Card Company: $cardName<br />\nCredit Card Number: $cardNum CID: $cid<br />\nCredit Card Phone Number: $bankNum<br />\n<br />\n$cartInfo<br /></body></html>"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; mail('stan@thinkingmachineonline.com', 'Thinking Machine Store order', $mailMessage, $headers); $myCart = new ShoppingCart(); echo "<div style='margin-left: auto; margin-right: auto; text-align: center;'>Your order has been processed, $name<br /><form action='{$_SERVER['PHP_SELF']}' method='post'><input type='submit' name='continue' value ='Continue Shopping' /></form></div>\n"; } else{ $cartInfo = $myCart -> emailMessage(); $mailMessage .= "<html><head><title>Order Confirmation</title></head><body>$name<br />\n$address1<br />\n$city, $state $zipcode<br />\nHome Phone Number: $homeNum<br />\nE-mail Address: $email<br />\n<br />\nCredit Card Company: $cardName<br />\nCredit Card Number: $cardNum CID: $cid<br />\nCredit Card Phone Number: $bankNum<br />\n<br />\n$cartInfo</body></html>"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; mail('stan@thinkingmachineonline.com', 'Thinking Machine Store order', $mailMessage, $headers); $myCart = new ShoppingCart(); echo "<div style='margin-left: auto; margin-right: auto; text-align: center;'>Your order has been processed, $name<br /><form action='{$_SERVER['PHP_SELF']}' method='post'><input type='submit' name='continue' value ='Continue Shopping' /></form></div>\n"; } } else{ echo "<div style='margin-left: auto; margin-right: auto; margin-top: 5px; text-align: center;'><a href='viewcart.php'><img src='images/store/storefront_02.jpg' alt='' /></a><img src='images/store/storefront_01a.jpg' alt='' /><a href='checkout.php'><img src='images/store/storefront_02a.jpg' alt='' /></a><div style='color: red; margin-left: auto; margin-right: auto; text-align: center;'>$errMessage</div>\n";?> <form name="checkout" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" style="margin-left: auto; margin-right: auto; text-align: center;"> <fieldset class="narrow"><legend>Please input your personal information</legend> <p><span style="color: red; font-size: 0.85em;">*Required fields.</span></p> <p><label for="name"><span style="color: red;">*</span>Name: </label><input type="text" name="name" value="<?php if(isset($_POST['name'])) echo $_POST['name']; ?>" /></p> <p><label for="address1"><span style="color: red;">*</span>Address 1: </label><input type="text" name="address1" value="<?php if(isset($_POST['address1'])) echo $_POST['address1']; ?>" /></p> <p><label for="address2"> Address 2: </label><input type="text" name="address2" value="<?php if(isset($_POST['address2'])) echo $_POST['address2']; ?>" /></p> <p><label for="city"><span style="color: red;">*</span>City: </label><input type="text" name="city" value="<?php if(isset($_POST['city'])) echo $_POST['city']; ?>" /></p> <p><label for="state"><span style="color: red;">*</span>State: </label><input type="text" name="state" value="<?php if(isset($_POST['state'])) echo $_POST['state']; ?>" size="2" maxlength="2" /></p> <p><label for="zipcode"><span style="color: red;">*</span>Zipcode: </label><input type="text" name="zipcode" value="<?php if(isset($_POST['zipcode'])) echo $_POST['zipcode']; ?>" /></p> <p><label for="home_num"><span style="color: red;">*</span>Home Telephone Number: <br /><span style="font-size: 0.75em;">(Include area code, but no dashes, spaces, or parentheses)</span></label><input type="text" name="home_num" value="<?php if(isset($_POST['home_num'])) echo $_POST['home_num']; ?>" /></p> <p><label for="email"><span style="color: red;">*</span>E-mail Address: </label><input type="text" name="email" value="<?php if(isset($_POST['email'])) echo $_POST['email']; ?>" /> </fieldset> <fieldset class="narrow"><legend>Please input your credit card information</legend> <p><span style="color: red; font-size: 0.75em;">*All fields are required.</span></p> <p><label for="card_name">Credit Card Provider: </label><select name="card_name"><option value="Mastercard">Mastercard</option><option value="Visa">Visa</option><option value="Discover">Discover</option><option value="American Express">American Express</option></select></p> <p><label for="card_num">Card Number: <span style="font-size: 0.75em">(No dashes or spaces)</span></label><input type="text" name="card_num" /></p> <p><label for="CID">CID: </label><input type="text" name="CID" value="<?php if(isset($_POST['CID'])) echo $_POST['CID']; ?>" size="4" maxlength="4" /></p> <p><label for="bank_num">Credit Card Telephone Number: <br /><span style="font-size: 0.75em;">(No dashes, spaces, or parentheses)</span></label><input type="text" name="bank_num" value="<?php if(isset($_POST['bank_num'])) echo $_POST['bank_num']; ?>" /></p> </fieldset><br /> <input type="submit" name="submit" value="Checkout" /><input type="submit" name="continue" value="Continue Shopping" /> </form> <a href="http://www.equifax.com/DigitalCertificates/"><img src="images/store/equifax.jpg" alt="Equifax SSL Security" /></a> </div> <?php } } else{?> <div style="margin-left: auto; margin-right: auto; margin-top: 5px; text-align: center;"><a href='viewcart.php'><img src='images/store/storefront_02.jpg' alt='' /></a><img src='images/store/storefront_01a.jpg' alt='' /><a href='checkout.php'><img src='images/store/storefront_02a.jpg' alt='' /></a> <form name="checkout" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" style="margin-left: auto; margin-right: auto; text-align: center;"> <fieldset class="narrow"><legend>Please input your personal information</legend> <p><span style="color: red; font-size: 0.85em;">*Required fields.</span></p> <p><label for="name"><span style="color: red;">*</span>Name: </label><input type="text" name="name" value="<?php if(isset($_POST['name'])) echo $_POST['name']; ?>" /></p> <p><label for="address1"><span style="color: red;">*</span>Address 1: </label><input type="text" name="address1" value="<?php if(isset($_POST['address1'])) echo $_POST['address1']; ?>" /></p> <p><label for="address2"> Address 2: </label><input type="text" name="address2" value="<?php if(isset($_POST['address2'])) echo $_POST['address2']; ?>" /></p> <p><label for="city"><span style="color: red;">*</span>City: </label><input type="text" name="city" value="<?php if(isset($_POST['city'])) echo $_POST['city']; ?>" /></p> <p><label for="state"><span style="color: red;">*</span>State: </label><input type="text" name="state" value="<?php if(isset($_POST['state'])) echo $_POST['state']; ?>" size="2" maxlength="2" /></p> <p><label for="zipcode"><span style="color: red;">*</span>Zipcode: </label><input type="text" name="zipcode" value="<?php if(isset($_POST['zipcode'])) echo $_POST['zipcode']; ?>" /></p> <p><label for="home_num"><span style="color: red;">*</span>Home Telephone Number: <br /><span style="font-size: 0.75em;">(Include area code, but no dashes, spaces, or parentheses)</span></label><input type="text" name="home_num" value="<?php if(isset($_POST['home_num'])) echo $_POST['home_num']; ?>" /></p> <p><label for="email"><span style="color: red;">*</span>E-mail Address: </label><input type="text" name="email" value="<?php if(isset($_POST['email'])) echo $_POST['email']; ?>" /> </fieldset> <fieldset class="narrow"><legend>Please input your credit card information</legend> <p><span style="color: red; font-size: 0.75em;">*All fields are required.</span></p> <p><label for="card_name">Credit Card Provider: </label><select name="card_name"><option value="Mastercard">Mastercard</option><option value="Visa">Visa</option><option value="Discover">Discover</option><option value="American Express">American Express</option></select></p> <p><label for="card_num">Card Number: <span style="font-size: 0.75em">(No dashes or spaces)</span></label><input type="text" name="card_num" /></p> <p><label for="CID">CID: </label><input type="text" name="CID" value="<?php if(isset($_POST['CID'])) echo $_POST['CID']; ?>" size="4" maxlength="4" /></p> <p><label for="bank_num">Credit Card Telephone Number: <br /><span style="font-size: 0.75em;">(No dashes, spaces, or parentheses)</span></label><input type="text" name="bank_num" value="<?php if(isset($_POST['bank_num'])) echo $_POST['bank_num']; ?>" /></p> </fieldset><br /> <input type="submit" name="submit" value="Checkout" /><input type="submit" name="continue" value="Continue Shopping" /> </form> <a href="http://www.equifax.com/DigitalCertificates/"><img src="images/store/equifax.jpg" alt="Equifax SSL Security" /></a> </div> <?php } include('../templates/sub_footer.inc'); ?>
  22. Name: Kevin Gender: Male (don't know too many female Kevin's....) Age: 26 I remember 'programming' on my Commodore VIC-20 when I was a little kid. Basically, we -- my brothers and I -- would just copy the instructions from one of the books we had of fun things to do with Basic. It was pretty cool making rockets out of *'s and watch them move up the screen. And, btw, Gorf and Radar Rat Race still own. I went to UNH to get my CS degree. I did alright until I got to assembly, and basically was stuck for two years before I figured I should at least get some sort of degree from there. So I went from Hell's Kitchen to Easy Bake Oven -- a communication degree. Gotta love liberal arts. Virtually all of my web development knowledge has been self-taught, either by me going to message boards like this one or by buying books and learning that way. I'm still a newb, but I'm making relatively steady progress. My university experience with C++ has helped in that regard, so variables, arrays, dynamic structures (lists, queues, stacks), and even simple objects are familiar territory. It's just a matter of learning how to implement them and when to use them.
  23. My username stems from a long, uninteresting, process. I came up with it back in '94.  I was 14 and my family had just subscribed to AOL (yeah yeah, I know...shut up :P).  I was going through that typical angsty teenage geek phase and wanted to come up with something unique, dark, and 'kewl.'  So, one day, in my freshman orientation class in high school, I looked over the shoulder of one of my friends to see what he was reading.  It was a Robert Jordan novel, and the page he was on mentioned the Kinslayer.  I thought that was interesting, but decided to make it 'darker,' so I came up with Nightslayer.  Unfortunately, AOL usernames at that time were limited to ten characters, so I had to modify the last portion of the name to make it fit. I've kept it ever since as, well, I figured I'd keep a static internet profile (so to speak).  So, yes, chances are any Nightslyr or Nightslayer you find online is me.  I also kept it because I'm too lazy to change my e-mail (which, thankfully, isn't on AOL any longer). ;)
  24. I have the Peachpit/Larry Ullman book, so I'm curious to know what the OP meant by 'old syntax' and if anyone can provide me with examples of what the (apparent) new standard is now. Thanks
×
×
  • 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.