1. Black Friday Sale - 50% off

    B4A Standard for $29 instead of $59!
    Buy Now
    Dismiss Notice

B4J Question [BANano]: [SOLVED] How to transverse elements by name and return attributes?

Discussion in 'B4J Questions' started by Mashiane, Jan 19, 2019.

  1. Mashiane

    Mashiane Expert Licensed User

    Hi there

    I'm trying to transverse some form elements by name, the example here gets all the inputs by a particular name e.g. category. This returns the two expected elements. In the future i'd like to serialize these without them having to be inside a 'form' tag.

    Issues: One of the elements is checked, the returned value is null however, the attribute property returns the right id. Is there a way to solve this?

    Sub GetMember1 As Boolean
    Dim elID As String = "category"
    Dim el As BANanoElement = BANano.GetElement($"input[name='${elID}']"$)
    Dim els() As BANanoElement = el.Siblings("")
    For Each radio As BANanoElement In els
    Log("*** type")
    Log("*** checked")
    Log("*** id")
    Log("*** value")
    Log("*** checked attr")
    Whilst the elements are read, I cant seem to get some of the attribute values..


    joulongleu likes this.
  2. alwaysbusy

    alwaysbusy Expert Licensed User

    Impossible to help without:

    1. seeing how it is created

    2. how the final html tag looks like

    3. how the transpiled javascript code looks like

    In short, a small project that can replicate the issues. I use these methods all the time without issues so something is particular in your case.
    joulongleu likes this.
  3. Mashiane

    Mashiane Expert Licensed User

    Thanks, I have attached an example..

    I see where my issue is now. The .GetElement output is actually 2 found radio items items, this is correct as per depicted by el.Length = 2. Running el.First returns the first element in that search, the correct input element. I saw there is an el.Last method also but what if I had more than 2 elements, how do I loop them and read each? That is where I'm stuck.

    Dim elID As String = "category"
    Dim el As BANanoElement = BANano.GetElement($"input[name='${elID}']"$)

    Attached Files:

    Last edited: Jan 20, 2019
    joulongleu likes this.
  4. alwaysbusy

    alwaysbusy Expert Licensed User

    Mashiane and joulongleu like this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice