- This topic has 3 replies, 2 voices, and was last updated 11 years, 3 months ago by support-octavio.
-
AuthorPosts
-
traceur78MemberHi there
I’m am New to app building and have some minimum experience with website development so I understand basic HTML, basic javascript, CSS etc
I have found most part of this forum very helpful in helping me create my first app and I’ve taken some ideas from others in the sense of coding (i hope that’s ok).
what I need help with is creating a code that shows an add/subtract total onto another page.
The code i’m using to show the total (ideas used from this site (i think)).
<html>
<head>
<script type=”text/javascript”>
function subtractQty(){
if(document.getElementById(“qty”).value – 1 < 0)
return;
else
document.getElementById(“qty”).value–;
}
</script></head>
<body>
<form name=”f1″>
<input type=’text’ name=’qty’ id=’qty’ />
<input type=’button’ name=’add’ onclick=’javascript: document.getElementById(“qty”).value++;’ value=’+’/>
<input type=’button’ name=’subtract’ onclick=’javascript: subtractQty();’ value=’-‘/>
</form>
</body>
</html>I would like to do something similar an existing app called ‘Mini Collector’. The app i’m working on is related to collecting ‘Trading Cards’ for various sports and vehicles etc.
I want to be able to show the total number of card of a specific type on the the main button image which is connect to the the total that’s added inside on the sub page.
Any help would be great thanks
Vinnie
support-octavioMemberHi Vinnie,
I assume that you are including all the code you shared in a HTML widget. You should only include content between <body> tags since this code is merged directly into the DOM. So putting next code in your HTML widget should work:
<script type="text/javascript"> function subtractQty(){ if(document.getElementById("qty").value - 1 < 0) return; else document.getElementById("qty").value--; } </script> <form name="f1"> <input type='text' name='qty' id='qty' /> <input type='button' name='add' onclick='javascript: document.getElementById("qty").value++;' value='+'/> <input type='button' name='subtract' onclick='javascript: subtractQty();' value='-'/> </form>
Also, please be aware that once you decide to use an HTML widget you are responsible for debugging its content, and you ought to test your code first in a mobile environment before embed it on a mobione app just to make sure that it works on mobile environment. This time we were able to help you out because it was something simple, but if you/users add 3rd party plugins or customized code and then report a problem would be hard for us to debug it
traceur78MemberHi
Thanks for the advice. It has been helpful, however what I wanted to show was the data from one HTML widget into another HTML widget. so I select the add or subtract on HTML Widget1 and the information appear on HTML Widget 1 & on HTML Widget 2 on a separate page (HTML Widget 2 doesn’t have the add/subtract function.
Is this possible?
Again, appreciate your advice and help.
Many Thanks
support-octavioMemberHi traceur78,
>Is this possible?
It is very doable. Remember that the code in both containers are embeded in the DOM. So, if you have a secondary HTML widget and want to pull the value of textbox of first HTML widget, you’d only have to access its value as you usually do and set it on this textbox on second HTML widget. Hope this make sense. -
AuthorPosts