Focal Point
[Solved] Chekbox name change on HTML page

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/4857053386

August 08, 2016, 09:09 AM
MeM
[Solved] Chekbox name change on HTML page
Hi,

I added a checkbox with the name 'ABC' on HTML page. The page also contains few dropdowns too and I want if a particular value from the dropdown is selected than the name of the checkbox changes to 'XYZ'.

I'm trying to do this from JavaScript function:

function On_Click(ctrl)
{
var a1 = IbComposer_getCurrentSelection('List_Box');
if (List_Box = "Honda")
{
document.getElementById('Show_check_Box').innerHTML = "ABC";
}
else
{
document.getElementById('Show_check_Box').innerHTML = "XYZ";
}
OnExecute(ctrl)
}

Can anybody please guide me what is the error in this code or Do I need to add anything more in this code?

Thank you in advance.

This message has been edited. Last edited by: MeM,


WebFOCUS 8.2.02
Windows, All Outputs
August 08, 2016, 09:32 AM
Squatch
if (List_Box = "Honda")

Should probably be:

if (a1 == "Honda")



App Studio
WebFOCUS 8.1.05M
Windows, All Outputs
August 08, 2016, 09:39 AM
MeM
Thank you Squatch. Do I also need to call this Javacript function from tasks and animations?


WebFOCUS 8.2.02
Windows, All Outputs
August 08, 2016, 09:52 AM
Squatch
You can create a task. Or you can click on your list box, then go to the Properties panel and click the yellow lightning bolt. Then you will see all the events for your list box. One of them should be the click event. You can type the name of your function there.


App Studio
WebFOCUS 8.1.05M
Windows, All Outputs
August 08, 2016, 10:22 AM
Squatch
You probably need to use the "value changed" event for your list box, not "on click".


App Studio
WebFOCUS 8.1.05M
Windows, All Outputs
August 08, 2016, 10:58 AM
MeM
Thank you Squatch but its not working.


WebFOCUS 8.2.02
Windows, All Outputs
August 08, 2016, 11:05 AM
Tony A
You also mention that you you need to change the "name" but then refer to "innerHTML" within the JavaScript.

Which is it meant to be? because they are not the same attribute. "name" will affect the variable name passed to WebFOCUS e.g. &ABC or &XYZ, whereas the "innerHTML" would affect the value passed.

That being said, if you are actually talking about a checkbox then check your understanding of what the "innerHTML" for a checkbox is!

Or are you talking about the label applied to a checkbox?


T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
August 08, 2016, 11:12 AM
MeM
Tony, I'm talking about the label applied to the checkbox


WebFOCUS 8.2.02
Windows, All Outputs
August 08, 2016, 11:27 AM
Squatch
I do not recommend working with the label in the checkbox. You cannot easily get to it because it is inside an HTML input tag, which is in turn inside a small HTML table which allows for multiple checkboxes. The ID of the checkbox is actually an HTML div tag that surrounds this table.

Instead, click on the checkbox and blank out the default checkbox label in the Settings panel. Then select a standalone "Label" under the Components tab. Place this label next to your checkbox. Then you can change it with "innerHTML" like you have in your example.


App Studio
WebFOCUS 8.1.05M
Windows, All Outputs
August 08, 2016, 11:39 AM
Tony A
quote:
I do not recommend working with the label in the checkbox.

This is why it is so important to get the actual issue details - we could have advised you to do something different! Smiler

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
August 08, 2016, 01:22 PM
MeM
Thank you Squatch and Tony. Now, I'm using standalone 'Label' but still its not working.


WebFOCUS 8.2.02
Windows, All Outputs
August 08, 2016, 02:18 PM
Squatch
I created a list box ("listbox1") with three selections: Honda, Mazda, Toyota.

I created a label ("label1").

I created a checkbox ("checkbox1"). I placed the label to the left of the checkbox.

If the selection is Honda, the label changes to ABC. If the selection is not Honda, it is XYZ.

I clicked on the list box and then in the Properties panel I clicked the yellow lightning bolt. I clicked on the right side of the "Value Changed" event and HTML Composer created the function "listbox1_onchange" automatically.

if(typeof(bRuntime) != 'undefined') {
// TODO: Add your inline runtime code here
}

//Begin function window_onload
function window_onload() {
UpdateData();

set_label();
}

function listbox1_onchange(event) {
    set_label();
}

function set_label() {
    var a1 = IbComposer_getCurrentSelection("listbox1");
 
    if (a1 == "Honda")
    {
        document.getElementById("label1").innerHTML = "ABC";
    }
    else
    {
        document.getElementById("label1").innerHTML = "XYZ";
    }
}



App Studio
WebFOCUS 8.1.05M
Windows, All Outputs
August 08, 2016, 02:56 PM
MeM
Thank you very much squatch, its working now.


WebFOCUS 8.2.02
Windows, All Outputs