Welcome! Log In Create A New Profile

Advanced

ASSIGNMENT 1 - CALCULATOR

Posted by 45966265 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
ASSIGNMENT 1 - CALCULATOR
January 26, 2013 05:10PM
Hey guys,

Working on my calculator question for ass1.
im using text fields for Input of Operand1&2 and Answer.
After submitting the form id like the answer to populate in the Answer text field. . . is this possible? How?

been searching but not come up with anything. . .
avatar Re: ASSIGNMENT 1 - CALCULATOR
January 27, 2013 02:40PM
Hi there

Echo the value inside the quotation marks of the value property like this:

Language: PHP
<input type="text" name="some_textbox" value="<?php echo $value_to_output; ?>" />
Re: ASSIGNMENT 1 - CALCULATOR
January 28, 2013 11:52AM
Ahh, thanks.

So i guess I would have to create another set of text fields then.
I was hoping to use the same Form Elements.
avatar Re: ASSIGNMENT 1 - CALCULATOR
January 28, 2013 01:40PM
You could still use the same elements. Use cookies or hidden fields to help preserve information through page loads.

----------------------------------------------------------------------------------------

int get_random_number() {
return 4;
}
avatar Re: ASSIGNMENT 1 - CALCULATOR
January 28, 2013 09:12PM
Using PHP code in the "VALUE" element/property works well. You can also review page 234 of the text book which relates to "Persisting User Data",
Jared
Re: ASSIGNMENT 1 - CALCULATOR
January 29, 2013 09:41AM
Thanks So much guys. im going to check that out.
il post my udpate soon.
Re: ASSIGNMENT 1 - CALCULATOR
February 03, 2013 10:26PM
Hi,
We have come back again, Happy new year to you all.
Re: ASSIGNMENT 1 - CALCULATOR
February 11, 2013 09:16AM
Dear fellow students,

Anyone, please e-mail me a copy of ICT3612 Tut_101 2013, my e-mail address: 39012182@mylife.unisa.ac.za

Thank You
avatar
Mac
Re: ASSIGNMENT 1 - CALCULATOR
February 11, 2013 11:47AM
Tut letters are copyrighted, so sending it on is an infringement....sad smiley If you are registered, you can download it from myUnisa...!
Re: ASSIGNMENT 1 - CALCULATOR
February 23, 2013 10:49AM
Hi Guys,

So, I managed to complete most of the calc.
I've now managed to get the Oper1, Oper2 & Result to display in the form elements.

Im having a problem however, with the SELECT list.
after I submit the Form, the correct Oper1, Oper2 and Result populate the Form elements. The Select Operator does not. it just defaults to the 1st, which is the "+".

Any idea what i should do?

iv tried this:
<select name="operators" value="<?php echo $operator; ?>" >
<option value="+">+</option>
<option value="-">-</option>
<option value="*">x</option>
<option value="/">/</option>
</select>

doesnt really work though.
Re: ASSIGNMENT 1 - CALCULATOR
February 23, 2013 11:06AM
Also having an issue when i enter a "0" in either operand. for some reason it takes the "0" as no value and throws my error to "Enter a value in the operand 1 or 2"
avatar
Mac
Re: ASSIGNMENT 1 - CALCULATOR
February 24, 2013 06:23PM
Being a bit tough here. Use FORMATTED code to post code...

how many times do I have to repeat this... how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...how many times do I have to repeat this...
Re: ASSIGNMENT 1 - CALCULATOR
February 26, 2013 09:30AM
Woops. . . Sorry Mac, I've never posted code online before. . . Lesson learned. smiling smiley

So, I managed to complete most of the calc.
I've now managed to get the Oper1, Oper2 & Result to display in the form elements.

Im having a problem however, with the SELECT list.
after I submit the Form, the correct Oper1, Oper2 and Result populate the Form elements. The Select Operator does not. it just defaults to the 1st, which is the "+".

Any idea what i should do?

Language: PHP
<select name="operators" value="<?php echo $operator; ?>" > <option value="+">+</option> <option value="-">-</option> <option value="*">x</option> <option value="/">/</option> </select>
avatar
Mac
Re: ASSIGNMENT 1 - CALCULATOR
February 26, 2013 11:43AM
The tut letter explains how to post formatted code smiling smiley

Do not use symbols as the value of the option.
Re: ASSIGNMENT 1 - CALCULATOR
February 27, 2013 04:01PM
I dont understand.

Do you mean in the option's value attribute?
what should I use then?
avatar
Mac
Re: ASSIGNMENT 1 - CALCULATOR
February 27, 2013 04:19PM
Use words.
Re: ASSIGNMENT 1 - CALCULATOR
February 27, 2013 08:07PM
Brilliance!!! smile thanks Mac!!
Re: ASSIGNMENT 1 - CALCULATOR
March 05, 2013 11:50AM
Hi there,

Don't know if you solved your 0 problem yet... If not I had the same issue and got an answer.

You are probably using the same statement I had to test if the field is empty...
Language: PHP
If (!$_POST[';num1';])

rather use...
Language: PHP
If ($_POST{';num1';] = "")

For some reasom if u use not post it sees 0 as nothing, so rather use if empty string... It worked for me.
avatar
Mac
Re: ASSIGNMENT 1 - CALCULATOR
March 05, 2013 12:50PM
See here for beter handling on empty fields http://www.htmlcenter.com/blog/empty-and-isset-in-php/
Re: ASSIGNMENT 1 - CALCULATOR
March 05, 2013 02:45PM
Tnax Mac,

I will def try that code 2nite, u r the best lec @ UNISA.
Now I understand why !$_POST didn't work well with 0.

Hoping to make u proud again this year.
Re: ASSIGNMENT 1 - CALCULATOR
March 05, 2013 03:15PM
Hi Mac,

I did test the code from suggested site...
It worked beautifully just had to reajust rest of my code.

Thanx a mil
IDE
March 07, 2013 10:20PM
Hi Everyone,

Can anyone recommend a PHP IDE that is easy to learn how to use in a short space of Time ?

Please assist
Re: ASSIGNMENT 1 - CALCULATOR
March 10, 2013 07:00PM
@49912232 -mbux,

If its for the course IDE's are not allowed as I understand, n++ or something alike sould be used. (Mac will b able 2 tell the dif...)

4 now I'm sticking with n++.

If its for yourself: (I havn't tried any of these yet)

http://en.wikipedia.org/wiki/List_of_PHP_editors
http://stackoverflow.com/questions/116292/what-is-the-best-ide-for-php
avatar
Mac
Re: ASSIGNMENT 1 - CALCULATOR
March 11, 2013 07:30AM
No IDE"S that generate complete code is allowed..
Re: ASSIGNMENT 1 - CALCULATOR
March 23, 2013 12:50AM
learn the technology you feel comfortable with do not let other people confuse you with many technologies you have a brain of a human being not computer

for example with me the tools i use are
for editing i use PSPad works fine for me (dreamweaver was making me lazy and forget coding cause it generated code for me so i no longer wanna see it next to me)
for front-end i use twitter bootstrap (pushing swaggthumbs up smileycool smiley - recently being nominated for best web front-end toolkit in the world)
and back-end i code from scratch if i am in a hurry i use CodeIgniter Frameworkhot smiley reason being it gives me the flexibility i need just saves me time and with it
i already learned the MVC software design pattern(not for unisa purposes)

Sorry to say this but CMS are crap to me Drupal,Joomla,Wordpress i dont have time to learn individual technologies reason being they are more focused in procedural approach than OOP
Trying to learn their plugins or edit template its mission impossible just try you will come and shake my hand i'm telling you

so choose your own tools carefully

matsoso K
Sorry, only registered users may post in this forum.

Click here to login