Discussion Forums  >  Uncategorized

Replies: 23    Views: 251

bigbodyg
Android Fan
Profile
Posts: 34
Reg: Dec 28, 2011
toronto
340
12/29/11 05:31 PM (14 years ago)

NEED HELP! Why wont this simple code work

hi i found this simple code for a calculator which has 2 field to enter numbers, and then you press ADD, or SUBRACT to do what you want. Entering numbers works Pressing the ADD or SUBTRACT doesnt - PLEASE HELP! I am using CUSTOM HTML as the TYPE CODE ------------- <html> <head> <title></title> <!-- Aim: Write HTML Code Using JavaScript Functions To Perform Basic Arithmetic Operations. --><!-- 1. Take Two numbers from user say 'Number 1' and 'Number 2'. --><!-- 2. Perform Addition, Subtraction, Multiplication, Division and Modulus. --><!-- 3. Result must be displayed on same HTML Page when respective button is clicked. --><!-- 4. Use <input> tag (HTML Forms Concept) with onclick.--><!-- 5. Call individual Javascript Function, put them inside <head> tag only.--><!-- 6. Javascript Tutorial/Code For Computer Science Students. --><!-- 7. Tested and Written By (c) Gaurav Akrani. --><script language=javascript type=text/javascript> function multiply(){ a=Number(document.calculator.number1.value); b=Number(document.calculator.number2.value); c=a*b; document.calculator.total.value=c; } </script><script language=javascript type=text/javascript> function addition(){ a=Number(document.calculator.number1.value); b=Number(document.calculator.number2.value); c=a+b; document.calculator.total.value=c; } </script><script language=javascript type=text/javascript> function subtraction(){ a=Number(document.calculator.number1.value); b=Number(document.calculator.number2.value); c=a-b; document.calculator.total.value=c; } </script><script language=javascript type=text/javascript> function division(){ a=Number(document.calculator.number1.value); b=Number(document.calculator.number2.value); c=a/b; document.calculator.total.value=c; } </script><script language=javascript type=text/javascript> function modulus(){ a=Number(document.calculator.number1.value); b=Number(document.calculator.number2.value); c=a%b; document.calculator.total.value=c; } </script> </head> <body> <!-- Opening a HTML Form. --> <form name=calculator> <!-- Here user will enter 1st number. -->Number 1: <input name=number1 type=text /> <!-- Here user will enter 2nd number. -->Number 2: <input name=number2 type=text /> <!-- Here result will be displayed. -->Get Result: <input name=total type=text /> <!-- Here respective button when clicked, calls only respective artimetic function. --><input onclick=javascript:addition(); type=button value=ADD /> <input onclick=javascript:subtraction(); type=button value=SUB /> <input onclick=javascript:multiply(); type=button value=MUL /> <input onclick=javascript:division(); type=button value=DIV /> <input onclick=javascript:modulus(); type=button value=MOD /> </form> <p>  </p> </body> </html>
 
bigbodyg
Android Fan
Profile
Posts: 34
Reg: Dec 28, 2011
toronto
340
like
12/29/11 05:45 PM (14 years ago)
** UPDate ** When i upload the code to the web, on a HTML page - and call that into the app - the code works fine? but this is using Custom URL - Webpage option...
 
GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
like
12/29/11 05:47 PM (14 years ago)
Hi @bigbodyg, When you add this code, are you adding it via Source instead of the default screen that comes up? If you paste source code into your Custom HTML screen, it needs to be done via the Source button on the editor. I'd keep some of the default code in there that Buzztouch provides, as it makes things work better for mobile devices. Mark
 
jeffb
Lost but trying
Profile
Posts: 40
Reg: Dec 23, 2011
location unknow...
400
like
12/29/11 06:21 PM (14 years ago)
From what I have observed, adding from source does no good. It still messes with your code. It stripes quotes and slashes.
 
GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
like
12/29/11 07:09 PM (14 years ago)
I've not had that issue with Buzztouch....it's usually the forum that strips things out! An alternative would be to create a normal HTML file, and either include it locally in the app, or refer to it remotely. Either of those are excellent options. Mark
 
jeffb
Lost but trying
Profile
Posts: 40
Reg: Dec 23, 2011
location unknow...
400
like
12/29/11 07:18 PM (14 years ago)
It happens both places. In another topic I tried to post what it was doing to my code with examples, and the forum screwed up my starting example. BT Server seems to replace symbols with something else and that just does not work for me. HTML that worked perfectly well in 1.3 in custom html will not work in BT server. At least for me.
 
jeffb
Lost but trying
Profile
Posts: 40
Reg: Dec 23, 2011
location unknow...
400
like
12/29/11 07:19 PM (14 years ago)
I don't mean to sound as ornery as that looks when I read it back. This place needs some smilies! ;o)
 
GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
like
12/29/11 07:25 PM (14 years ago)
Hi @jeffb, I agree that there are some issues in BT Server, and that what you're describing is one of them. I was assuming that this post related to the standard Buzztouch v1.5 - @bigbodyg , what say ye? BT Server or normal BT? Mark
 
Paul Rogers
Android Fan
Profile
Posts: 2524
Reg: May 30, 2011
UK
35,740
like
12/29/11 07:29 PM (14 years ago)
ornery, love it! lol! Never heard or seen that outside of movies :-) Wonder if your bt server problem is something to do with your hosting or permissions? Might be worth investigating?
 
GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
like
12/29/11 07:35 PM (14 years ago)
Hi @raveyd, Being that I live in the southwest, aka Old West, we use ornery all the time! I think I've seen this issue mentioned several times in the forum, with reference to BT Server, so I suspect it's under investigation. Mark
 
jeffb
Lost but trying
Profile
Posts: 40
Reg: Dec 23, 2011
location unknow...
400
like
12/29/11 07:36 PM (14 years ago)
I thought maybe I had the wrong type of character set in my database, but I checked it and it was what was recommended for the install. I'm pretty sure it is that WYSIWYG editor. It's still having it's way with the code even when you save it in the code mode.
 
Paul Rogers
Android Fan
Profile
Posts: 2524
Reg: May 30, 2011
UK
35,740
like
12/29/11 07:56 PM (14 years ago)
heehee! still love it! thanks @jeffb and @GoNorthWest. Go on, write it again! lol! Has that problem only arisen in a recent server update? I'm a few versions behind and have no problems. Or have some people always had the issue?
 
Paul Rogers
Android Fan
Profile
Posts: 2524
Reg: May 30, 2011
UK
35,740
like
12/29/11 08:15 PM (14 years ago)
Double post... odd...
 
David @ buzztouch
buzztouch Evangelist
Profile
Posts: 6866
Reg: Jan 01, 2010
Monterey, CA
78,840
like
12/30/11 03:36 AM (14 years ago)
Sounds like we all understand the baseline at least. Forum replaced crazy characters to keep them out of our database (we hate this too). But, the HTML editor does not. What you paste in the HTML editor should remain, all crazy characters included. If the editor in your install is NOT reloading and redisplaying what you paste in the Code View, something is wrong. Because this is a BT server question, you can do a simple test. First, how it works. The data you paste in the WYSIWYG editor is NOT saved to the database. When you click 'save' in the editor (custom html screen), the contents of the editor are saved to a .html file in the app's documents directory on the server (every app has it's own documents directory). All your doing is creating a new web-page on the server with a .html file type. Nothing fancy, simple file. Cut > Paste > Save creates this file. The phone downloads the file from the URL to your control panel. The URL the phone downloads for a custom HTML screen may look like ......domain...BT-server/files/applications/[APPGUID]/documents/customHTML_[SCREENGUID].html You can see this webpage (the one made by the editor) in your regular browser too. To see where this is saved and the page is created, have a look at the plugins AJAX_save.php method in the custom html plugin folder. Scroll down to line 195 or so and you'll see where it saves the contents of the editor to the file system (creates the .html page). Hope this helps.
 
jeffb
Lost but trying
Profile
Posts: 40
Reg: Dec 23, 2011
location unknow...
400
like
12/30/11 06:51 AM (14 years ago)
David, I tested it before I asked the initial question on a different topic. I'll post the url of the document here created by BT Server, and the html document I used for the original code. Look at the source, and you will see how the BT Editor save the code, and this was working only in the html view, and saving while in the html view. http://www.forestryforum.com/BT-Server/files/applications/EAE5DFD528AAAF8FC42995D67/documents/customHTML_6EE485420FA9DF025CBC8D9.html http://www.forestryforum.com/countdown.htm You are right, there is definitely a problem. ;o)
 
jeffb
Lost but trying
Profile
Posts: 40
Reg: Dec 23, 2011
location unknow...
400
like
12/30/11 07:16 AM (14 years ago)
The editor escapes every instance of a quotation mark, which essentially kills most javascripts.
 
bigbodyg
Android Fan
Profile
Posts: 34
Reg: Dec 28, 2011
toronto
340
like
12/30/11 09:17 AM (14 years ago)
i did paste it into the source :) so right now it works - as a html page on the web linking into the app. i will try putting the local html file in the build and see how that works just in case people dont have internet access i want the app still working.
 
GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
like
12/30/11 12:33 PM (14 years ago)
Hi @bigbodyg, Glad you were able to get it working, and good idea to move it to a local HTML page. The Custom HTML/Text screen always requires a connection to the Internet in order to download the source for the page, so using that screen type could be problematic. I always try and use a local HTML page, and just update it via an app update. Won't work in every situation, but in most it should. Mark
 
bigbodyg
Android Fan
Profile
Posts: 34
Reg: Dec 28, 2011
toronto
340
like
12/30/11 02:02 PM (14 years ago)
in which situation does the APP NOT UPDATE??
 
GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
like
12/30/11 03:00 PM (14 years ago)
This might help in understanding online vs offline apps: http://www.buzztouch.com/resources/Understanding_App_Refresh_and_Offline_Apps_v1.0.pdf However, certain screens, like Custom HTML/Text are always online. And, of course, if you reference any external file, it'll need a connection to the Internet. But, you can have an offline app, from the perspective of app refresh, but still have it access online docs. Make sense? ;-) Mark
 
PSMDanny
Apple Fan
Profile
Posts: 1166
Reg: Dec 09, 2011
Heerlen
21,940
like
12/30/11 04:15 PM (14 years ago)
Hi bigbodyg, from what I understand, I had similar problems with the editor. See the next url to my post in which I also present the solution. Let me know if this is equal to your problem (and if it solves yours). http://www.buzztouch.com/forum/thread.php?tid=EF114BF7690FACB5BBB33BE&status=&searchInput=Magic_quotes&sortColumn=FT.dateStampUTC&sortUpDown=DESC¤tPage=1&doViews=1 Best Regards, Danny
 
jeffb
Lost but trying
Profile
Posts: 40
Reg: Dec 23, 2011
location unknow...
400
like
12/30/11 05:00 PM (14 years ago)
Was there ever any indications given on how to just turn it off in BT Server rather then setting the .htaccess file for the whole server?
 
PSMDanny
Apple Fan
Profile
Posts: 1166
Reg: Dec 09, 2011
Heerlen
21,940
like
12/30/11 05:06 PM (14 years ago)
Hi jeffb, Don't know if it will work but put the .htaccess file in the bt-server directory (maybe then it only affects this directory). Placing the .htaccess file in the root of the domain will only affect the domain your working on (not on the rest of your server. If you have a reseller account and can create multiple domains on a server). On the other side: magic_quotes is deprecated so you better not use it anymore. Best Regards, Danny
 
jeffb
Lost but trying
Profile
Posts: 40
Reg: Dec 23, 2011
location unknow...
400
like
12/31/11 11:55 PM (14 years ago)
It is hard to answer here when you don't know what is going to happen to the text in your post.;o( You simply put the representative Ascii code where you would want the plus sign to be. From that link I gave you use the code from the HTML number column.
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.