Enjoy an ad free experience by logging in. Not a member yet? Register.
|
|
Results 1 to 7 of 7
Thread: JavaScript Button Text
-
04-06-2016, 03:46 PM #1New to the CF scene
- Join Date
- Apr 2016
- Posts
- 4
- Thanks
- 0
- Thanked 0 Times in 0 Posts
JavaScript Button Text
Hey All,
First Post...
A little intro, I am a new software/mobile developer but over 13yr's in the IT industry.
I have just hit a road-block that for the life of me, cannot over-come.
Seeking advice...
I have a single button called "pc3LoadSELECT" that opens up a pop up with a new button called "loadCol_1" and loadCol_1 gets up to 150 options from local_storage.
What I need to work out is how to get "pc3LoadSELECT" label SELECT to change to whatever value is present in loadCol_1.
EG: If I choose 150 then the label SELECT will replace with 150.
The 2 set's of code I have played around with are:
&Code:$('a[dsid="pc3FitmentSELECT"]').text("");
Code:var listOfLabels = ['loadCol_1']; function getRandomLabel() { return listOfLabels[Math.floor(Math.random() * listOfLabels.length) + 1]; } $('a[dsid="pc3LoadSELECT"]').text("");
I will admit, in this 1 task I have been set, I am absolutely blind. So any help in attempting to work out or try to workout what is needed.
The data present isn't random and I shall attach an image which will show the range of options possible for this 1 button in the popup (a small sample).


Please advise?
-
04-06-2016, 03:59 PM #2Senior Coder
- Join Date
- Jan 2010
- Location
- Behind the Wall
- Posts
- 4,556
- Thanks
- 14
- Thanked 476 Times in 471 Posts
did you check that the selection actually catches something? dsid isn’t a valid HTML attribute, so browsers may strip it off.
The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.André Behrens, NY Times Software Developer
-
04-06-2016, 04:03 PM #3New to the CF scene
- Join Date
- Apr 2016
- Posts
- 4
- Thanks
- 0
- Thanked 0 Times in 0 Posts
Hey Dormilich,
I should've mentioned,
This is for a mobile application, JS (JavaScript) for this bit only,
It'll be packaged up for IOS & Android (both confirmed to work with JS),
Thank you,
- Benj
-
04-07-2016, 01:14 AM #4Master Coder
- Join Date
- Jan 2011
- Location
- Washington
- Posts
- 6,251
- Thanks
- 30
- Thanked 859 Times in 857 Posts
tech-xcellent you don't make much sense, but I think I got it.
You have a button like this:
and that will generate a new button in a popup that gets info from an array and you want that info to change the text written on the first button. If I'm correct this does it. Just hit the second button, loadCol_1, to do that.Code:<button onclick="MakePopUp" id="magicbutton">pc3LoadSELECT</button>
Code:<!DOCTYPE html> <html> <head> <title>New document</title> </head> <body> <button onclick="MakePopUp" id="magicbutton">pc3LoadSELECT</button> <button onclick="getRandomLabel()">loadCol_1</button> <script> var listOfLabels = ["Banana", "Orange", "Apple", "Mango"]; function getRandomLabel(){ var lab = listOfLabels[Math.floor(Math.random() * listOfLabels.length) + 1]; document.getElementById("magicbutton").childNodes[0].nodeValue= "pc3Load"+lab; } </script> </body> </html>Evolution - The non-random survival of random variants.
Physics is actually atoms trying to understand themselves.
-
04-07-2016, 01:53 AM #5New to the CF scene
- Join Date
- Apr 2016
- Posts
- 4
- Thanks
- 0
- Thanked 0 Times in 0 Posts
@sunfighter.
I do apologize, trying to explain anything isn't a strong point for me.
I have all the button's & list's built and ready to go, using the Appery.io system (client choice, not mine)
I am limited exclusively to JavaScript,
So is there some fashion or method that you know off to get a button's text SELECT to change to whatever was selected by the end user?
EG: from my popup, I click on 180 or 122 or 95 etc... all from loadCol_1 (the name of the button) and the main button's text SELECT will change to what was selected.
I hope this helps,
Thank you,
- Benj
-
04-07-2016, 01:59 AM #6New to the CF scene
- Join Date
- Apr 2016
- Posts
- 4
- Thanks
- 0
- Thanked 0 Times in 0 Posts
@sunfighter,
To shed some light,
The button pc3LoadSELECT button open's up a popup, this popup has 18 button's present (loadCol_1 to loadCol_18), each button gets up to 150 or more option's based on previous choice's.
I am focusing on 1 button so I can, with help work out what exactly is needed and go from there
.
These value's that appear are not random, they are infact programmed in already, so I need help to work out how to get 1 button's label/text SELECT to change based on what was selected.
I hope this is helpful as well.
Thank you,
- Benj
-
04-07-2016, 01:02 PM #7Master Coder
- Join Date
- Jan 2011
- Location
- Washington
- Posts
- 6,251
- Thanks
- 30
- Thanked 859 Times in 857 Posts
I gave you what you need. Did you run the code?
Having 15 secondary buttons does not change the idea. But you will have to determine the variable 'lab' for each of the 15, probably by way of passing in an identifier to the function.Evolution - The non-random survival of random variants.
Physics is actually atoms trying to understand themselves.



Reply With Quote
