PDA

View Full Version : General Coding Support Thread


Syndicate
08-12-2008, 08:20 PM
Need help with writing a piece of code for a program, flash, a web app, or even plain old HTML? Post your issue here.

Fiend1138
09-08-2008, 01:31 AM
Does anyone know the HTML or CSS code to place one pic over another? I can't replace the original image so I have no choice but to cover it up. I'm trying to do this:

http://i37.tinypic.com/2z6bbwx.jpg

Satan
09-08-2008, 01:50 AM
Post your code as it is right now.

Fiend1138
09-08-2008, 01:57 AM
the source code doesn't help, trust me... it uses a template based back end service that looks like this:

http://s4.tinypic.com/5ufjvs.jpg

So pretty much all i can do is paste code into a text box field...

RedBEARD
09-08-2008, 01:14 PM
Without knowing a whole lot (well, anything) about that system, you could conceivably write a CSS document that has IDs for layouts that could cover that area - question is if whether or not the CSS would function correctly given it's apparently a ready-made layout.

Is there a reason why you guys went with that as a hosting option?

Distortion
09-08-2008, 01:58 PM
why don't you just photoshop it?

Distortion
09-08-2008, 02:05 PM
i'm trying to fire two javascripts on my onlick event, only firing the second one if the first event returns true, not sure the right syntax, would it be

onclick="return(CheckAlerts()&&ValidateScripts());"

Fiend1138
09-08-2008, 02:07 PM
why don't you just photoshop it?

it is photoshopped, i have the image all ready i just need to figure out how to pop the pic in there...

and Red, we went with that because at the time none of us knew shit about any type of coding, they were cheap and had a piss load of features. it really is a good site.

Syndicate
09-08-2008, 02:10 PM
i'm trying to fire two javascripts on my onlick event, only firing the second one if the first event returns true, not sure the right syntax, would it be

onclick="return(CheckAlerts()&&ValidateScripts());"

Put the second event on a onMouseUp. So it'd go something like

<a href="#" onClick="WHATEVER SCRIPT#1" onMouseUp="WHATEVER SCRIPT#2">

Syndicate
09-08-2008, 02:13 PM
it is photoshopped, i have the image all ready i just need to figure out how to pop the pic in there...

and Red, we went with that because at the time none of us knew shit about any type of coding, they were cheap and had a piss load of features. it really is a good site.

Just by taking a look at the website for Bandzoogle I'd say your fucked. It looks like they cut out all the functionality one would need to modify anything that isn't listed in yoru Admin CP. In short they made the site 100% idiot proof, which is good for people that don't know shit about coding, but as a downside you are unable to get into the actual code and change/modify it directly.

Satan
09-08-2008, 03:47 PM
i'm trying to fire two javascripts on my onlick event, only firing the second one if the first event returns true, not sure the right syntax, would it be

onclick="return(CheckAlerts()&&ValidateScripts());"
You can go with what Syndicate said, or you can have a third function to handle both, that’s usually the way I approach that problem.



onclick=”return masterFunction()”

function masterFunction() {
variable = firstFunction();
if(variable){
secondFunction();
}
}


As far as Fiend's problem, does the element you want to change have an ID? And if it doesn't, can you add javascript? There is a way to name and change an element with JS.

Fiend1138
09-08-2008, 03:47 PM
well i just emailed them to try to get access to our code, so if i can then hopefully i can tweak the code...

Distortion
09-08-2008, 04:25 PM
well i just emailed them to try to get access to our code, so if i can then hopefully i can tweak the code...


would using something like this work, where just add you image anywhere and set the position to whichever one lets you place it anywhere on the screen (i think it's absolute) and then just set it's location

<img style="position:absolute; top:0; left:0;"

Rumpleforeskin
02-24-2009, 09:56 PM
I'm workin on my C++ assignment but it somehow got stuck in infinite loop. Is there a way to stop this so I can find out what is wrong?

Limp
02-24-2009, 10:20 PM
Got a Pause or Break key?

Rumpleforeskin
02-25-2009, 06:22 AM
The program itself is in infinite loop, and it gets shut down before there is any output since it keeps going.

chickenparm
02-25-2009, 08:22 AM
Depending on which IDE you're using, you should learn to work the debug feature. But if you could paste or PM me the code, I would be much more useful. I can't help if I'm not looking at it line by line.

Rumpleforeskin
02-26-2009, 05:19 PM
I'm taking an intro to C++ class online. It's not hard but im rrtrded when it comes to compooterz. I use Microsoft Visual Studios (2008) to make my programs. Here is the new problem:

btw I will pay cash money for help


Combining While Loops and If Statements
Write a program that reads a series of numbers (doubles) from the user, then prints the mean and the
range.
Notes:


You do not know ahead of time how many numbers will be in the list.


When you want to stop entering numbers, enter control‐Z.


The range is the difference between the lowest and the highest number.
• The numbers will be in the range of 0.0 to 100.0. Ignore any numbers outside of this range.

RedBEARD
02-26-2009, 07:42 PM
Not to sound like a total douche, but if you Google the first sentence of your assignment, you probably will wind up finding a ready-made solution.

Rumpleforeskin
02-26-2009, 07:46 PM
Yeah, I guess I could try that. It was already recommended but I didn't try it out of laziness. Thanks.

RedBEARD
02-26-2009, 07:48 PM
It's not all that difficult of an assignment, seems typical of beginner level courses. How familiar are you with the language?

Rumpleforeskin
02-26-2009, 08:04 PM
It is a beginner course. And I was doing relatively well until more math became involved (integers and whatnot). I've already found the exact same program solved on the internet, but in it they use commands we haven't touched on yet. Here's what I have:


#include <iostream>
#include <string>
using namespace std;
int main()
{
double num1, counter, total, min, max, average, range;
while ((num1 =< 0) || (num1 =<100))
{
cin >> num1;
if

if (num1 > max)
max = num1;

if (num1 < max)
min = num1;
counter++;
total += num1;
}
average = total/counter;
range = max - min;
cout << "The average is " << average << endl;
cout << "The range is " << range << endl;
}

I'm basically having problems getting it to ignore numbers that are not within the parameters of the question.

chickenparm
02-26-2009, 11:12 PM
Use whitespace, use brackets with your if statements to keep things clean, add comments, and remember to use indentations to stay organized. Your code looks pretty good, but I don't have M$ VS on this computer, and don't have the time to download it. Your loop control is messed up, and that will solve the parameter issue. So, it should be:

while ((num1 >= 0.0) && (num1 <= 100)) {

And I'm not entirely sure how to break the loop with ctrl + z without breaking the program.

Rumpleforeskin
02-27-2009, 05:51 AM
I'm still having parameter problems. It compiles fine, but the average is off, and the range is more than it is supposed to be. Plus, sometimes there is no output when there is supposed to be. BTW thanks for you help.

Rumpleforeskin
02-28-2009, 10:00 PM
Here is a new problem:


Assignment 18
Combining Comparisons
There is a secret government organization called PIB which only accepts recruits who fit
their criteria (shown below). If you fit any of the combinations of criteria, then you can
apply to work for PIB. Write a program which asks the user appropriate questions (ask
all the questions up front) and then determines if the candidate is acceptable. Use the
screen shots as a guide.
Here are the rules:
• If you are male between the ages of 18 and 30 (inclusive) you may apply.
• If you are female between the ages of 18 and 32 (inclusive) you may apply.
• If you are male between the ages of 18 and 35 (inclusive) and either were in the
military or you can do at least 50 pushups in a row you may apply.
• If you are female between the ages of 18 and 40 (inclusive) and either were in the
military or you can do at least 30 pushups in a row you may apply.
• No one else is eligible.
Screen shot samples:


Here is what I have so far:

#include <iostream>
#include <string>

using namespace std;

int main()
{
string name, military;
char gender;
int age, pushups;
cout << "What is your full name?" << endl;
getline(cin, name);
cout << "How old are you?" << endl;
cin >> age;
cout << "Where you ever in the military? (yes/no)" << endl;
cin >> military;
cout << "How many pushup can you do in a row?" << endl;
cin >> pushups;
cout << "Are (m)ale or (f)emale?" << endl;
cin >> gender;

{
while (gender == f)
if ((age >= 18) && (age <= 32))
if (((age >= 18) && (age <= 40)) && (miltary = yes))
cout << "Yes, " << name << ", you may apply." << endl;
else
cout << "Sorry, " << name << ", your are not eligible." << endl;

while (gender == m)
if ((age >= 18) && (age <= 30))
if (((age >= 18) && (age <= 35)) && (military = yes))
cout << "Yes, " << name << ", you may apply." << endl;
else
cout << "Sorry, " << name << ", you are not eligible." << endl;
}
}


Here is what it says the error is from:

Errors:

./files/137-VYA5014.cpp: In function 'int main()':./files/137-VYA5014.cpp:30: error: 'f' was not declared in this scope./files/137-VYA5014.cpp:32: error: 'miltary' was not declared in this scope./files/137-VYA5014.cpp:32: error: 'yes' was not declared in this scope./files/137-VYA5014.cpp:37: error: 'm' was not declared in this scope./files/137-VYA5014.cpp:39: error: 'yes' was not declared in this scope


Any ideas? Thanks in advance.

DjAg
03-07-2009, 05:07 PM
It seems to be a very old post and I assume you've moved past this fairly easy assignment... But anyways.

Glancing over the code quickly, I can say that if you are to compare strings and characters and such, you might want to either declare constants (a waste IMO) or put the 'm' and 'f' and such in quotes and/or find the ASCII equivalent of those letters (ASCII suggestions would only work for 'char').

Also you misspelled 'military' when handling females between the ages of 18 and 40... Also, I would recommend using only one if statement in those, since using 2 demands over-clarification which will produce inaccurate results. (for example, a 20 year old woman who has not been in the military will be rejected automatically sinc ethe next if clause will block it from ever reaching the 'yes' output.

I would also recommend working on your brackets and such, as they are a little bit sloppy which results in not only us being confused, but can result in programming errors by both the compiler and yourself.


I tend to overuse brackets and paranthesis and then clean them up after if they are unnecessary, but realistically, they don't hurt to any extent and keep things more organized... Try something along these lines (excuse any inaccuracies, I code in java 99.99% of the time, not C++... It's been years)

if ((gender == 'f') && (age >= 18) && (age <= 40)) {
if ((age <= 32) || (military == "yes") || (pushups >= 30)) {
cout << "Yes, " << name << ", you may apply." << endl;
}
else {
cout << "Sorry, " << name << ", you are not eligible." << endl;
}
}

else if ((gender == 'm') && (age >= 18) && age <= 35) {
if ((age <= 30) || (military == "yes") || (pushups >= 50)) {
cout << "Yes, " << name << ", you may apply." << endl;
}
else {
cout << "Sorry, " << name << ", you are not eligible." << endl;
}
}

else {
cout << "Sorry, " << name << ", you are not eligible." << endl;
}