Web Dev Questions That Don't Need Their Own Thread v4
5,001 replies, posted
[QUOTE=01271;40172707]I do but I'm wondering how I'm going to make a grid work from within my site.
I've done grids before and it's always been in programs where I'll just ask for a grid then start placing my elements and they'll just snap to the grid. I have no experience placing elements on a page otherwise and Dreamweaver's not an image editing program so I don't know how I'll do that anyways.
Oh yeah and my designs using grids suck but that's beside the point.
Poorly worded last post on my part.
I should probably use this thread when I have a genuine quantifiable problem instead of a frustration.[/QUOTE]
Okay that makes more sense in that context. Generally if someone is telling you you should use a grid it means you should make sure that things line up nicely more than anything. Check things like making sure the nav and logo and content area all line up on the sides, small stuff like that goes a long way.
I thought about something before. What if you make it so instead of using password you have a whitelist which you add IP on. People whos not on the whitelist get redirected to another site and people on the blacklist gets redirected to a black list page.
would that be a good idea? Could anyone link me in the right direction for something like this?
[QUOTE=SweFox*;40180376]I thought about something before. What if you make it so instead of using password you have a whitelist which you add IP on. People whos not on the whitelist get redirected to another site and people on the blacklist gets redirected to a black list page.
would that be a good idea? Could anyone link me in the right direction for something like this?[/QUOTE]
In the UK we have dynamic ip addresses so that wouldn't be practical. My IP address changes every day.
[QUOTE=daniel_c;40180493]In the UK we have dynamic ip addresses so that wouldn't be practical. My IP address changes every day.[/QUOTE]
Right, I forgot about dynamic ips. I guess you're right. Would be a fun thing to do though.
[QUOTE=SweFox*;40180376]I thought about something before. What if you make it so instead of using password you have a whitelist which you add IP on. People whos not on the whitelist get redirected to another site and people on the blacklist gets redirected to a black list page.
would that be a good idea? Could anyone link me in the right direction for something like this?[/QUOTE]
Not a good idea but you could do this with the Mac Address, or even with Static IP but only on a secure LAN because otherwise you will always have someone with the same IP or MAC, would be rare this last but possible.
IP - Postal Code/Zip Code
Mac - Postal Address/Address
-snip-
Hi I have a question about CSS...
The pic says everything:
[IMG]http://i48.tinypic.com/nffnkg.png[/IMG]
This would remove the orange part but it will probably break the layout.
[CODE]display: inline-block;[/CODE]
[QUOTE=Worre;40182823]This would remove the orange part but it will probably break the layout.
[CODE]display: inline-block;[/CODE][/QUOTE]
thats how it looks after your advice :/
[IMG]http://i50.tinypic.com/25ameme.png[/IMG]
---------------------------------------
Problem solved with another div function. Anyways thanks.
Well, I did say it would probably break the layout.
Actionscript 3 problem:
Basically I have a timer, and after one second it's supposed to change scenes to the scene named "Transport"
MovieClip(this.root).gotoAndPlay(1, "Transport");
But it's not working. It keeps changing back to the scene I already was on. What am I doing wrong?
[PHP]//Transport
import flash.events.TimerEvent;
import flash.utils.Timer;
var timer:Timer = new Timer(1000, 1);
timer.addEventListener(TimerEvent.TIMER, fl_ClickToGoToScene_14);
Transport.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndPlayFromFrame_2);
function fl_ClickToGoToAndPlayFromFrame_2(event:MouseEvent):void
{
timer.start();
gotoAndPlay(29);
}
function fl_ClickToGoToScene_14(event:TimerEvent):void
{
timer.stop();
MovieClip(this.root).gotoAndPlay(1, "Transport");
}
[/PHP]
What I'm doing with that code is that I press a button, then it plays a few frames on the current scene and after 1 second it switches to another scene. Basically it plays an exiting animation then switches pages.
[QUOTE=mac338;40185091]Actionscript 3 problem:
Basically I have a timer, and after one second it's supposed to change scenes to the scene named "Transport"
MovieClip(this.root).gotoAndPlay(1, "Transport");
But it's not working. It keeps changing back to the scene I already was on. What am I doing wrong?
[PHP]//Transport
import flash.events.TimerEvent;
import flash.utils.Timer;
var timer:Timer = new Timer(1000, 1);
timer.addEventListener(TimerEvent.TIMER, fl_ClickToGoToScene_14);
Transport.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndPlayFromFrame_2);
function fl_ClickToGoToAndPlayFromFrame_2(event:MouseEvent):void
{
timer.start();
gotoAndPlay(29);
}
function fl_ClickToGoToScene_14(event:TimerEvent):void
{
timer.stop();
MovieClip(this.root).gotoAndPlay(1, "Transport");
}
[/PHP]
What I'm doing with that code is that I press a button, then it plays a few frames on the current scene and after 1 second it switches to another scene. Basically it plays an exiting animation then switches pages.[/QUOTE]
As far as I'm aware you should change
[code]MovieClip(this.root).gotoAndPlay(1, "Transport");[/code]
to
[code]nextScene();[/code]
or
[code]gotoAndPlay(1, "Transport");[/code]
No need to go through the movieclip. Since the movieclip is just a part of the scene. And since you're changing the entire scene you can just do it from "root", so to speak.
Yeah, I changed ti to gotoAndPlay, and simplified the code a lot. Now it works brilliantly.
How do I make it so that selecting a form element selects a few other form elements?
Say I had a form here:
[code]
SELECT ALL [ ][√]
Red [ ][√]
Blue [ ][√]
[/code]
And if I press select all it switches Red and Blue to "ON" instead of "OFF" on the form.
[code]
SELECT ALL [√][ ]
Red [√][ ]
Blue [√][ ]
[/code]
I'm going to be using radio buttons btw.
[QUOTE=01271;40207377]How do I make it so that selecting a form element selects a few other form elements?
Say I had a form here:
[code]
SELECT ALL [ ][√]
Red [ ][√]
Blue [ ][√]
[/code]
And if I press select all it switches Red and Blue to "ON" instead of "OFF" on the form.
[code]
SELECT ALL [√][ ]
Red [√][ ]
Blue [√][ ]
[/code]
I'm going to be using radio buttons btw.[/QUOTE]
-snip- didn't check your layout
You do however want to use javascript & name the buttons in groups
[QUOTE=01271;40207377]How do I make it so that selecting a form element selects a few other form elements?
Say I had a form here:
[code]
SELECT ALL [ ][√]
Red [ ][√]
Blue [ ][√]
[/code]
And if I press select all it switches Red and Blue to "ON" instead of "OFF" on the form.
[code]
SELECT ALL [√][ ]
Red [√][ ]
Blue [√][ ]
[/code]
I'm going to be using radio buttons btw.[/QUOTE]
You can solve this by using Javascript. If you are using jQuery this will do:
[code]
$(document).ready(function() {
$("[name=all]").change(function(ev) {
$(".off, .on").prop('checked', false);
$("." + ev.target.id).prop('checked', 'checked');
});
});
[/code]
As seen here: [del][url]http://jsfiddle.net/erBQM/1/[/url][/del] edit: updated: [url]http://jsfiddle.net/erBQM/3/[/url]
Without jQuery you could use this:
[code]
function selectAll(r_on) {
var radios = document.getElementsByTagName('input');
for (var i = 0; i < radios.length; ++i) {
if(radios[i].className === r_on.toString()) {
radios[i].checked = 'checked';
}
}
}
[/code]
As seen here:
[del][url]http://jsfiddle.net/E9Wn3/[/url][/del] edit: use this instead; [url]http://jsfiddle.net/E9Wn3/1/[/url]
Note that for the jQuery one to work, you'll need 2 radio buttons that turn everything on and off, with id's that match the ones that have to get checked with them. Also the 2 base radio buttons will need to have the name 'all'.
For the second one you need to place the js in the head, and the 2 base radio buttons need this html attribute:
onchange="selectAll('off'); <-- for the one group with class 'off'
onchange="selectAll('on'); <-- for the other group with class 'on'
[url]http://maxnorelax.com[/url]
works fine scaled down on the computer
on phones, super messed up. looks like clearing issues. I'm a little bit of a noob, how do I fix it?
[QUOTE=eternalflamez;40208399] edit: use this instead; [url]http://jsfiddle.net/E9Wn3/1/[/url][/QUOTE]
This is amazing, thank you. How do I use it over and over on a single form?
[QUOTE=Glitchman;40209098][url]http://maxnorelax.com[/url]
works fine scaled down on the computer
on phones, super messed up. looks like clearing issues. I'm a little bit of a noob, how do I fix it?[/QUOTE]
"one free unban" sounds like something that shouldn't matter to player who use the server unless you're ban happy and it also sounds like "grief what you took a picture of". Just an insight.
[QUOTE=01271;40209638]This is amazing, thank you. How do I use it over and over on a single form?
"one free unban" sounds like something that shouldn't matter to player who use the server unless you're ban happy and it also sounds like "grief what you took a picture of". Just an insight.[/QUOTE]
It's not made for a single form with multiples of radiobuttons, not to worry though I'll figure something out.
I'll keep you updated.
[editline]8th April 2013[/editline]
[QUOTE=eternalflamez;40209831]It's not made for a single form with multiples of radiobuttons, not to worry though I'll figure something out.
I'll keep you updated.[/QUOTE]
[url]http://jsfiddle.net/E9Wn3/4/[/url]
How it works:
[code]
<div id="unique_id">
<input type="radio" name="unimportant" onchange="selectAll('unique_id_off');" />
<input type="radio" name="unimportant" onchange="selectAll('unique_id_on');" />
<br/>X:
<input type="radio" name="red" class="unique_id_off" />
<input type="radio" name="red" class="unique_id_on" />
<br/>Y:
<input type="radio" name="blue" class="unique_id_off" />
<input type="radio" name="blue" class="unique_id_on" />
</div>
<div id="another_unique_id">
<input type="radio" name="unimportant2" onchange="selectAll('another_unique_id_off');" />
<input type="radio" name="unimportant2" onchange="selectAll('another_unique_id_on');" />
<br/>A:
<input type="radio" name="red2" class="another_unique_id_off" />
<input type="radio" name="red2" class="another_unique_id_on" />
<br/>B:
<input type="radio" name="blue2" class="another_unique_id_off" />
<input type="radio" name="blue2" class="another_unique_id_on" />
</div>
[/code]
Just be careful that the thing in the "selectAll('')" is the same as the class you want to toggle with it.
And that you use unique names everywhere in the form, and unique id's for the divs. Aka standard html.
(And the js needs to be above the inputs themselves.)
Edit: and the div id is the same as the class id without the last part. It needs the underscore in the class names to identify which div it is in.
[QUOTE=01271;40209638]
"one free unban" sounds like something that shouldn't matter to player who use the server unless you're ban happy and it also sounds like "grief what you took a picture of". Just an insight.[/QUOTE]
It's a hardcore server where if you die, you can't come back for a week (banned technically)
[CODE]
$('.desc-box').mouseover(function( e ) {
e.preventDefault();
slideshow.pause();
clearTimeout();
});
$('.desc-box').mouseleave(function( e ) {
e.preventDefault();
slideshow.resume();
});
[/CODE]
What i want to make is an div which show the content with an hover and when i leave the div with the mouse, it should take 3 seconds to make the slideshow.resume(); event. But it should stop the action if im gonna hover over the div again.
[QUOTE=MarcoPixel;40218343][CODE]
$('.desc-box').mouseover(function( e ) {
e.preventDefault();
slideshow.pause();
clearTimeout();
});
$('.desc-box').mouseleave(function( e ) {
e.preventDefault();
slideshow.resume();
});
[/CODE]
What i want to make is an div which show the content with an hover and when i leave the div with the mouse, it should take 3 seconds to make the slideshow.resume(); event. But it should stop the action if im gonna hover over the div again.[/QUOTE]
This seems fine but you forgot one thing:
[code]
$('.desc-box').mouseover(function( e ) {
e.preventDefault();
slideshow.pause();
clearTimeout();
});
$('.desc-box').mouseleave(function( e ) {
e.preventDefault();
setTimeout(function () {
slideshow.resume();
}, 3000);
});
[/code]
Setting the timeout on the resuming. You clear it but you never set it. Instead your piece of code would probably just do it instantaneously, right?
Anyway if you use the code above it should work.
Is this method of putting data into a Mysql DB insecure?
If so can you show me a securer way?
[PHP]$insertBadge = "INSERT INTO `badges` ( `name` , `desc` , `ach`, `img`, `category`, `updated`) VALUES ('$name', '$desc', '$ach', '$img', '$cat', '$date')";
mysql_query($insertBadge) or die('MySQL Error.');
[/PHP]
Thanks
Probably not:
- You need to escape any input using mysql_real_escape_string or similar;
- The mysql_ functions are not recommended, use mysqli or PDO ([url=http://www.php.net/manual/en/mysqli.overview.php#mysqli.overview.mysqlnd]comparison table[/url])
I want to start learning ruby, I know how to code but have a few questions.
Ruby on Rails is a good a way to start learning ruby?
In php I just put upload my files to the server and I'm done, can I do that with ruby or what I need? Btw local server I just use xampp, what I need for ruby?
[QUOTE=asantos3;40220559]I want to start learning ruby, I know how to code but have a few questions.
Ruby on Rails is a good a way to start learning ruby?
In php I just put upload my files to the server and I'm done, can I do that with ruby or what I need? Btw local server I just use xampp, what I need for ruby?[/QUOTE]
I started with Ruby on Rails without knowing about Ruby beforehand and I got trough it. I would still suggest to learn the language on it's own though.
Ruby on Rails are web applications, which means that you cannot just 'drop files' and load them. You have to actually start the application. There is the development mode though which reloads the necessary files per-request.
Installing ruby is not that hard, but it depends on the platform you are on. If windows is your dev platform, this has worked fairly well for me: [url]http://railsinstaller.org/[/url]
Together with a WAMP stack I then had everything I needed.
So I install ruby on my server (with that I could install rails, right?), then I simple start a application and code, or just reload necessary files I made in a local server?
I think I will just leave it in a corner, right I find it much more easier to drop files and load them.
I'll mature my knowledge in php and javascript, witch I could also make server-side stuff with node.js.
With rails, you really have to go with a VPS or a cloud platform (like [url=https://www.heroku.com/]heroku[/url]) in order to run it on a server.
You run code in "development", "testing", and "production". When you're writing code, you run the application in development mode to see things in your browser and interact with your site. It implements code reloading, which allows you to see changes you make to the files in the browser with merely a page reload. When you're running it on a server for people it use, you run the application in production mode; this removes information from error pages, and removes code reloading - basically, removing things that aren't needed in production. Testing is when you run tests on your application, but I haven't been writing tests and I'm a terrible person because of it.
It's not like php where you can drag and drop it into place and voilà, you have a site. It is a program that was written in the ground up in Ruby, and is ran as an actual server - it can act like PHP-FPM, if you've ever used that. There are many things that are used for ruby's server in production, like [url=http://code.macournoyer.com/thin/]thin[/url], [url=http://puma.io/]puma[/url], [url=https://github.com/defunkt/unicorn]unicorn[/url], and [url=https://www.phusionpassenger.com/]passenger[/url] (I personally use passenger).
It's also different from regular ruby in that it makes many modifications to core classes of ruby, such as the Numeric class which allows you to do stuff like 4.minutes.ago (which is not something you'd normally be able to do in ruby).
Ruby also comes with its own package manager, [url=https://rubygems.org/]gem[/url], that allows you to install gems (or libraries) on to your computer or wherever. So installing rails is not a matter of downloading a few files and placing them in the right place but just "gem install rails". This is also regulated by [url=http://gembundler.com/]bundler[/url] to download the needed libraries for an application and at the right version the application needs (the [url=https://github.com/redjazz96/chattr/blob/master/Gemfile]Gemfile[/url] and [url=https://github.com/redjazz96/chattr/blob/master/Gemfile.lock]Gemfile.lock[/url]).
Oh, and [url=https://blog.engineyard.com/2013/learning-rails-and-ruby]this blog post[/url] is pretty cool too.
Could anyone tell me how (if it is possible) to connect two divs so the colours will folow each other?
[IMG]http://i.imgur.com/ERzfgIO.png[/IMG]
(Just to demonstrate what I didn't want.)
Sorry, you need to Log In to post a reply to this thread.