Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Radiobutton choices

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Radiobutton choices

    I wish to display some data in a grid, and for each record in the grid give the user a list of options on radiobuttons which are related to this record. The list of options is held in a table � the number of options is variable. I can see how to create some radiobuttons, with a dynamic list of choices, but what I need to do is to pass a value from the main record on which to base the selection criteria for the list of radiobuttons. Does anyone know how to do this? Or are there any other techniques that may help?

    #2
    Re: Radiobutton choices

    Could you elaborate; not sure what you mean by 'selection criteria' being passed.
    Steve Wood
    See my profile on IADN

    Comment


      #3
      Re: Radiobutton choices

      Hi Steve,
      I have 2 SQL Server tables � questions and options. Let�s say that the first record in the question table is �What is the capital of France�. There are 4 records in the options table which relate to this question: �Berlin�, �London�, �Paris�, �Madrid�. The second row in the questions table is �Where is Lyon?�, with 4 records in the options table: �Spain�, �Germany�, �England�,�France�.
      When I display question 1 to the user, I want to display the 4 options that relate to the question, from which the user must select only one, so I thought I would use radio buttons for this. Then display question 2, with its 4 options. Therefore, when listing the options as radio buttons, I need to restrict the list of choices to the 4 options that relate to the question.
      I have tried setting a field on the grid as a radiobutton control type, but when specifying the dynamic radiobutton choices I can�t see how to set up the SQL command to only select records from the options table where a field in the options table = the field from the questions table.
      Is this any clearer? Or is there another technique that I could use to display a list of choices to the user?

      Comment


        #4
        Re: Radiobutton choices

        You can do it, but you have to work outside of the Grid's radiobutton object to do so. The radiobutton, dropdown, checkbox fields do not allow you to create a dynamic filter right in the object's "Filter" field. Instead of basing your selection field on a table, you define it as from a Variable. (List type=Dynamic >Data Source Type=Variable).

        You then have to create your variable somewhere else, normally in the same A5W page where the grid resides. (In v10 you can populate the variable from the grid events, or the A5W page. In v9, only from an a5w page.

        So presumably if your user is viewing question #123, then "123", or an ID representing question #123, is sitting in the URL or a variable somehow at the time the user is looking at that question.

        If so, then in the A5W page you can populate your variable like this:

        answerchoices = table.external_record_content_get([PathAlias.ADB_Path]\myanswers","answerset","sequence","id="+quote(x))

        where x is whatever variable is holding the current question ID. For instance, if you had questionno in the url, x would be "questionno".
        Steve Wood
        See my profile on IADN

        Comment


          #5
          Re: Radiobutton choices

          I was browsing for a solution to related issue and came across this. I had a similar issue, I dont understand Steves comments, he's a guru and I'm still learning but what I did answered this albeit not as elegantly so hopefully it helps someone.

          I learnt to create a UDF (User defined function) in the grid control where I wanted to have the multi choice options appear, basically (and it was not for the feint hearted) the UDF takes some values from the grid, in this case the grid would be based on and gleaned from the questions table (e.g. QuestionID and current row number) and passes these to a function I wrote.

          To create somewhere to put the UDF I had to create a dummy field in my grid, to create the dummy field I inserted into my SQL statement a new column e.g. DummyColumn AS '' then in the grid I made the control type a UDF.

          The purpose of the Xbasic function is then to take the QuestionID which gest passed in from the UDF and use it to make it an argument that forms part of a SQL query that talks to the Answers table (which stores the QuestionID as the FK) and returns the related answers (options) related to the QuestionID. So you know have the options related to your question. Once you have them in your record set (I call my record set variable rs) you then apply the .tostring() method to the record set i.e. rs.tostring() which puts the returns values into a nice crlf string (basically each option ends up on its own line) then you use what is called an A5 helper function called A5_radiobuttons() . This is a funky little function that takes a number of parameters including the crlf string. Its job in life is turn the options into a list of radio buttons. A critical parameter you must pass into this is a javascript event handler that manages the user interaction of changing options. Unfortunately to do this you need to learn to write a javascript function.

          Here is what my UDF function looked like:
          AnswerOptions_render = "<div style=\"width:800px; word-wrap: break-word; \" id=\"radioBtn_"+Args.RowNumber+"\">" + generateAnswerOptions(Data.QuestionID,Data.Answer,Args.RowNumber)+"</div>"

          Here is what my xbasic function looked like
          function generateAnswerOptions as c (questionID as n, selectedAnswer as c, currentRowNumber as n)
          dim html as c
          dim choices as c
          dim args as sql::Arguments
          dim cn as sql::Connection
          dim sqlCommand as c
          dim rs as sql::ResultSet
          'debug(1)
          args.Set("filter",questionID)'set the argument to the value of question which is passed into the function at the start from the trigger
          cn.open("::name::PaT")
          sqlCommand = "SELECT Answer FROM [SOPPaC_Steps_Q_Answers] where QuestionID =:filter" 'pull in the answers that are filtered by the filter
          cn.Execute(sqlCommand,args)
          rs = cn.ResultSet 'stuff em into a variable called rs as a ResultSet
          choices = rs.tostring()'convert ResultSet into a crlf string and whack these into a variable called choices
          html = a5w_radiobuttons(choices, "AnswerOptions_" + currentRowNumber,"" ,"","vertical","onchange=setanswer("+currentRowNumber+")","AnswerOptions_" + currentRowNumber)
          'use the a5w_radiobuttons() helper function to create the html code for the radio buttons
          generateAnswerOptions = html 'set the function to the value ofthe html code we have just created
          cn.Close()
          end function

          Here is the javascript function I wrote (this is an event handler that is put inside the a5w_radiobuttons() helper function
          //this gets triggered by the onChange event of the freeform field that contains the radio button choices
          //it takes the value of the selected answer and puts it in the answer field

          function setanswer(RowNum) {
          var answer = $gvs('AnswerOptions_'+ RowNum);
          answer = $u.s.tran(answer,'\n',',');
          //call a function in here that looks up the ID and returns it
          {grid.object}.setValue('G','ANSWER',RowNum,answer);
          }

          There is some other stuff I do with this but it works pretty well. The issue I am having with it at the moment is my answers can be quite long and a) I cant figure out how to make the text wrap, I can break the words using a style attribute but not text wrap and b) if I use an html editor the formatting goes crazy from time to time. I've gone back to no html editor. If anyone has an answer for that I'd love to know I've played with style settings everywhere I can think to (except for in the helper function) and every style setting I can find.

          Good luck

          Comment

          Working...
          X