Jump to content

Get value from radio button


Recommended Posts

Hi all, sorry for late reply... I have tried all post and seems nothing worked, when I execute it, checking is online is hanging(please take look at whole script), and Kickstarter15, Subz post, when I tried to choose one of the radio button it was triggered endless loop, I wonder why though even I have re-check that I wrote the same as you guys did..

Link to comment
Share on other sites

Sorry for double post, I cant find the edit button :D

As 232Showtime advised with $vRadio = ControlGetText($Form1_1, "", $radio1), I have tried it using IF THEN ... 

If $radio1 = $GUI_CHECKED Then
    $vRadio = ControlGetText($Form1_1, "", $radio1)
Else
    $vRadio = ControlGetText($Form1_1, "", $radio2)
EndIf

the logic always fall to ELSE because the state is not choosen at all, but when I choose another option, the value from $vRadio is not changed, is there any function like jquery/javascript that if the option is change the value is changed also? I tried to google it but seems not having any luck..

Link to comment
Share on other sites

@anub13 The script requires a lot of work to tidy the code up, it's extremely difficult to read, here is what I can tell:

The Select statement isn't in a loop and occurs during the Gui build so because by default no radio is selected, $chkPatrol = "".  So try this, replace Func StartForm() with the following:

What it does is checks the radio button when it's pressed and updates the edit box accordingly, if you switch radio options it will update the editbox again.  By default Categ = "" since neither radio is selected.

Hope that helps.

Func _CheckPatrol()
    Local $bChkPatrol = False
    Select
        Case GUICtrlRead($radio1) = $GUI_CHECKED
            $chkPatrol = $Wise
            $bChkPatrol = True
        Case GUICtrlRead($radio2) = $GUI_CHECKED
            $chkPatrol = $Internet
            $bChkPatrol = True
    EndSelect
    If $bChkPatrol = True Then
        GUICtrlSetData($txtInfo,"ADDITIONAL INFORMATION THAT WILL BE SENT WITH THE MESSAGE:" & @CRLF & ASDFGSystemInfo())
        $bChkPatrol = False
    EndIf
EndFunc

func StartForm()
    GUICtrlSetData($txtInfo,"ADDITIONAL INFORMATION THAT WILL BE SENT WITH THE MESSAGE:" & @CRLF & ASDFGSystemInfo())
    GUISetState(@SW_SHOW)
    AdlibRegister("_CheckPatrol")
    While 1
        $nMsg = GUIGetMsg()
        Select
            case $nMsg = $txtEmailAddress
                GUICtrlSetData($txtInfo,"ADDITIONAL INFORMATION THAT WILL BE SENT WITH THE MESSAGE:" & @CRLF & ASDFGSystemInfo())
            case $nMsg = $txtPhone
                GUICtrlSetData($txtInfo,"ADDITIONAL INFORMATION THAT WILL BE SENT WITH THE MESSAGE:" & @CRLF & ASDFGSystemInfo())
            case $nMsg = $txtFullName
                GUICtrlSetData($txtInfo,"ADDITIONAL INFORMATION THAT WILL BE SENT WITH THE MESSAGE:" & @CRLF & ASDFGSystemInfo())
            Case $nMsg = $cmdScreenShot
                $gScreenShotFile =  SaveScreenShot()
            case $nMsg = $cmdSubmit
                if ValidateForm() then
                    if ASDFGSubmit() Then
                        UpdateStatus("Your request has been sent successfully")
                        MsgBox(0,"Help Requested","Your request has been sent successfully")
                        ExitLoop
                    Else
                        MsgBox(0,"Help Failed","Something is wrong you request was not sent, please try again")
                    Endif
                endIf
            case $nMsg = $cmdAttach
                $gAttachFile = AttachFile()

            Case $nMsg = $GUI_EVENT_CLOSE
                ExitLoop
        EndSelect
    WEnd
    AdlibUnRegister("_CheckPatrol")
EndFunc

 

Link to comment
Share on other sites

Hi Subz,

Thank you for the explanation, I tried your code and when choose the radio button output from ASDFGSystemInfo() , the $txtInfo GUI keep scrolling back up.. I can't see the result.... I think the problem is with the ASDFGSystemInfo(), please take a look at this code

 

if $isAdminVersion=0 then
        $ASDFGInfo = $ASDFGInfo & @CRLF & " Ticket Tags:" & @CRLF
        $ASDFGInfo = $ASDFGInfo & "~userphone='" & GUICtrlRead($txtPhone) & "'" & @CRLF
        $ASDFGInfo = $ASDFGInfo & "~submitterphone='" & GUICtrlRead($txtPhone) & "'" & @CRLF

        dim $MachineID
        $MachineID = KaseyaIni($gKIniFile,"SERVER COMMUNICATIONS","User_Name","NotFound")
        $ASDFGInfo = $ASDFGInfo & "~machineid='" & $MachineID & "'" & @CRLF

        dim $OrgGroups
        $OrgGroups= StringSplit($MachineID,".")

        dim $OrgGroupIndex
        $OrgGroupIndex = UBound($OrgGroups) - 1
        $ASDFGInfo = $ASDFGInfo & "~organization='" & $OrgGroups[$OrgGroupIndex] & "'" & @CRLF

        dim $EmailUser
        $EmailUser = GUICtrlRead($txtEmailAddress)
        $EmailUser = StringMid($EmailUser,1,StringInStr($EmailUser,"@") - 1)

        $ASDFGInfo = $ASDFGInfo & "~username='" & $EmailUser & "'" & @CRLF

        dim $categ
        $categ = $bChkPatrol
        $ASDFGInfo = $ASDFGInfo & "~category='" & $categ & "'" & @CRLF

        $ASDFGInfo = $ASDFGInfo & "~afterhour='" & $AfterHour & "'" & @CRLF
    endif

If the $categ = $bChkPatrol it was giving error like this(please see pict)

and If I change the $categ = $chkPatrol the script can be complied and showing bug? as I said in first sentence.

Sorry if I am slow learner :( be easy on me.

Capture.PNG

Link to comment
Share on other sites

Change it to $chkPatrol, $bchkPatrol is only for the _CheckPatrol function it shouldn't be used anywhere else otherwise it won't allow you to scroll the editbox, when you compiled the script and run it, click either of the radio buttons it should update.

Link to comment
Share on other sites

1 minute ago, Subz said:

Change it to $chkPatrol, $bchkPatrol is only for the _CheckPatrol function it shouldn't be used anywhere else otherwise it won't allow you to scroll the editbox, when you compiled the script and run it, click either of the radio buttons it should update.

As I said in the previous reply I have tried that and the $txtInfo GUI keep scrolling back up when I tried to see the value.. just to confirm you meant the $categ = $chckPatrol right?

Link to comment
Share on other sites

Can you replace _CheckPatrol with the following and yes please leave $categ = $chkPatrol

Func _CheckPatrol()
    Local $bChkPatrol = False
    Select
        Case GUICtrlRead($radio1) = $GUI_CHECKED
            If GUICtrlRead($radio1, 1) <> $chkPatrol Then
                $chkPatrol = $Wise
                $bChkPatrol = True
            EndIf
        Case GUICtrlRead($radio2) = $GUI_CHECKED
            If GUICtrlRead($radio2, 1) <> $chkPatrol Then
                $chkPatrol = $Internet
                $bChkPatrol = True
            EndIf
    EndSelect
    If $bChkPatrol = True Then
        GUICtrlSetData($txtInfo,"ADDITIONAL INFORMATION THAT WILL BE SENT WITH THE MESSAGE:" & @CRLF & ASDFGSystemInfo())
        $bChkPatrol = False
    EndIf

 

Link to comment
Share on other sites

OMG! It did the trick! You are awesome Subz!

Thanks people who are responding and spent your time reading and try to help my problem! Very much appreciated! I can't say anymore word beside thank you very much.

In some future I might ask more problem :D

Link to comment
Share on other sites

As I told you in your first post that this forum can help you if you can provide more codes and details.:lol: Cheerss..!! Glad to help and welcome to autoit.

I can assure you that Subz is one of the best in this forum.:P

Programming is "To make it so simple that there are obviously no deficiencies" or "To make it so complicated that there are no obvious deficiencies" by C.A.R. Hoare.

Link to comment
Share on other sites

4 hours ago, anub13 said:

Sorry for double post, I cant find the edit button :D

As 232Showtime advised with $vRadio = ControlGetText($Form1_1, "", $radio1), I have tried it using IF THEN ... 

If $radio1 = $GUI_CHECKED Then
    $vRadio = ControlGetText($Form1_1, "", $radio1)
Else
    $vRadio = ControlGetText($Form1_1, "", $radio2)
EndIf

the logic always fall to ELSE because the state is not choosen at all, but when I choose another option, the value from $vRadio is not changed, is there any function like jquery/javascript that if the option is change the value is changed also? I tried to google it but seems not having any luck..

it will jump to else because the line is waiting for  $GUI_CHECKED, you can try it like this

If $radio1 = $GUI_CHECKED Then
    $vRadio = ControlGetText($Form1_1, "", $radio1)
EndIf

If $radio2 = $GUI_CHECKED Then
    $vRadio = ControlGetText($Form1_1, "", $radio2)
EndIf

anyway its working... cheers...:P

 

ill get to that... i still need to learn and understand a lot of codes graduated.gif

Correct answer, learn to walk before you take on that marathon.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...