Jump to content

Compare URL to Value of IE Checkbox


Recommended Posts

Hey guys, 

I'm quite a bit confused right now as I'm encountering a problem I can't solve. 

 

Is it possible to compare the value of a checkbox with the text in the url?

 

 

For example :

URL:  www.example.com/admin/categories/.php?page=example&path=example2

 

On this site, I have the names of several products.

* For each product there is a checkbox.

* The name of each product is a link

* If I click on one of those names, a menu opens. I can't use it tho, because I need to activate the checkbox first.

    - For example to move the Product to another Category

 

Let's say, there's a product called "Example Product 1"

Now I click on this link by 

_IELinkClickByText($oIE, "Example Product 1")

 

After doing so, the URL changes to : 

www.example.com/admin/categories/.php?page=example&path=example2&ID=98765

 

but I'm still on the same site as before, with all the products and the checkboxes. 

Now all of those Checkboxes have specific Values. For example : 

 

Checkbox1 Value 12345

Checkbox2 Value 98765

Checkbox3 Value 456987

 

As you can see, the ID in the URL fits with one of those Checkboxes. 

Is it possible to automatically check the checkbox fitting to the ID in the URL?

 

Like on this example, check Checkbox2 since the Value is the same as the ID in the url?

 

 

Can't find a way to make this work. Kind regards and thanks in advance!

 

 

Link to comment
Share on other sites

My Idea is something like this :

 

Get the URL as a variable :

$Link_Artikel = _IEPropertyGet ($oIE, "locationurl")

 

So $Link_Artikel would have the value www.example.com/admin/categories/.php?page=example&path=example2&ID=98765

Those links are always ending with  "&ID=number" . 

 

Now I'd like to extract the "number" behind the &ID= and I just can't figure out how I do that.

 

I could create a new variable then like 

$CheckboxID = (_Func_To_Extract_ID)

 

Then I could compare this $CheckboxID to the checkboxes with _IEFormElementGetValue. But I just can't figure out how to get the ID extracted 

Link to comment
Share on other sites

The Name of the Checkbox is always : multi_products[], they only differ by value

So I'd go by this : 

 

Func _Compare_Checkbox



$oForm = _IEGetObjById($oIE, "multi_action_form")

$link_artikel = _IEPropertyGet ($oIE, "locationurl")

$link_id = _ExtractID_from_URL()

$oCheckArticle = _IEFormElementGetObjByName($oForm, "multi_products[]")

$check_value =  _IEFormElementGetValue($oCheckArticle) 



If $Link__ID = $check_value then

;check the box

EndIf



EndFunc





Func _ExtractID_from_URL()



;I have no clue how to do this



EndFunc


    
  

Something like this should work imo, but I'm kinda stuck on it. Trying to take a deeper look into stringinstring right now

Link to comment
Share on other sites

Sure. The checkbox sits in a Table with the other elements of the Article. 

 

<!-- This is one of the tables -->

<tr class="dataTableRow" style="cursor: pointer;" onmouseover="this.className='dataTableRowOver';this.style.cursor='pointer'" onmouseout="this.className='dataTableRow'">

                 <td class="categories_view_data">

<!-- This is the Checkbox -->
                   
                   <input name="multi_products[]" class="ChkBox" type="checkbox" value="17226"><em>&nbsp;</em>                 </td>

Is this enough ?

Link to comment
Share on other sites

So you could use something like (untested):

Local $sLink_Artikel = _IEPropertyGet ($oIE, "locationurl")
Local $aLink_Artikel = StringSplit($sLink_Artikel, "=")
Local $iLink_Artikel = $aLink_Artikel[$aLink_Artikel[0]]
Local $oInputs = _IETagNameGetCollection($oIE, "input")
If IsObj($oInputs) Then
    For $oInput In $oInputs
        If $oInput.ClassName = "ChkBox" Then
            If $oInput.Value = $iLink_Artikel Then _IEAction($oInput, "click")
        EndIf
    Next
EndIf

 

Link to comment
Share on other sites

Thanks a lot Subz, that worked!

 

Func _Kategorien()

$Artikellink = $Artikelname
_IELinkClickByText($oIE, $Artikelname)

Local $sLink_Artikel = _IEPropertyGet ($oIE, "locationurl")
Local $aLink_Artikel = StringSplit($sLink_Artikel, "=")
Local $iLink_Artikel = $aLink_Artikel[$aLink_Artikel[0]]
Local $oInputs = _IETagNameGetCollection($oIE, "input")
If IsObj($oInputs) Then
    For $oInput In $oInputs
        If $oInput.ClassName = "ChkBox" Then
            If $oInput.Value = $iLink_Artikel Then _IEAction($oInput, "click")
        EndIf
    Next
EndIf

EndFunc

 

Link to comment
Share on other sites

Facing another Problem right now. I have a few other checkboxes like this : 

<input type="checkbox" name="dest_cat_ids[]" value="380" class="ChkBox">
<input type="checkbox" name="dest_cat_ids[]" value="150" class="ChkBox">

 

They are in the same form as the boxes in the problem above.  I've tried to click them by value , like this : 

 

Func _Kategorien()

$Artikellink = $Artikelname
_IELinkClickByText($oIE, $Artikelname)

Local $sLink_Artikel = _IEPropertyGet ($oIE, "locationurl")
Local $aLink_Artikel = StringSplit($sLink_Artikel, "=")
Local $iLink_Artikel = $aLink_Artikel[$aLink_Artikel[0]]
Local $oInputs = _IETagNameGetCollection($oIE, "input")
If IsObj($oInputs) Then
    For $oInput In $oInputs
        If $oInput.ClassName = "ChkBox" Then
            If $oInput.Value = $iLink_Artikel Then _IEAction($oInput, "click")
        EndIf
    Next
EndIf

_Click_Kopieren()

EndFunc



Func _Click_Kopieren()
$oButtons = _IETagnameGetCollection($oIE, "input")
For $oButton in $oButtons
    If String($oButton.value) = "Kopieren" Then
        _IEAction($oButton, "click")
        ExitLoop
    EndIf
Next

_KategorienAuswahl()
EndFunc



Func _KategorienAuswahl()

_Check_Kategorie()

Local $oInputs = _IETagNameGetCollection($oIE, "input")
If IsObj($oInputs) Then
    For $oInput In $oInputs
        If $oInput.ClassNameName = "ChkBox" Then
            If $oInput.Value = $CheckKategorie Then _IEAction($oInput, "click")
        EndIf
    Next
EndIf
EndFunc


Func _Check_Kategorie() ; For example, when $google2 = Deckenleuchte and $Material = "Metall" then I want to check the box with the value 150

IF $google2 = "Deckenleuchte" AND $Material = "Metall" Then
$CheckKategorie = 150
EndIf


EndFunc

 

But I can't get it to work. Could you might point out my mistake so I can find a way to solve this? Thanks in advance!

Link to comment
Share on other sites

"Kopieren" is the value of the button I want to click, this is working. 

The only thing not working is the following code :

 

Func _KategorienAuswahl()

_Check_Kategorie()

Local $oInputs = _IETagNameGetCollection($oIE, "input")
If IsObj($oInputs) Then
    For $oInput In $oInputs
        If $oInput.ClassNameName = "ChkBox" Then
            If $oInput.Value = $CheckKategorie Then _IEAction($oInput, "click")
        EndIf
    Next
EndIf
EndFunc

 

Here's the form : 

 

<form name="multi_action_form" action="---current url---" method="post" onsubmit="javascript:return CheckMultiForm()">

it's inside a table :

<table class="tableBody">
      <tbody><tr>

Inside this form is another table with the checkboxes I want to check :

 

<td class="infoBoxContent">
<input type="checkbox" name="dest_cat_ids[]" value="356" class="ChkBox"><em>&nbsp;</em><font size="1">Hersteller</font><br>
<input type="checkbox" name="dest_cat_ids[]" value="361" class="ChkBox"><em>&nbsp;</em><font size="1">&nbsp;&nbsp;&nbsp;Albert</font><br>
<input type="checkbox" name="dest_cat_ids[]" value="359" class="ChkBox"><em>&nbsp;</em><font size="1">&nbsp;&nbsp;&nbsp;Anta</font><br>
<input type="checkbox" name="dest_cat_ids[]" value="360" class="ChkBox"><em>&nbsp;</em><font size="1">&nbsp;&nbsp;&nbsp;Artemide</font><br>
<input type="checkbox" name="dest_cat_ids[]" value="362" class="ChkBox"><em>&nbsp;</em><font size="1">&nbsp;&nbsp;&nbsp;B+M Leuchten</font><br>
<input type="checkbox" name="dest_cat_ids[]" value="364" class="ChkBox"><em>&nbsp;</em><font size="1">&nbsp;&nbsp;&nbsp;B-Leuchten</font><br>
etc..

 

 

And I'm having trouble accessing those checkboxes.

Link to comment
Share on other sites

Things I tried so far :

 

Func _KategorienAuswahl()

    $oForm = _IEFormElementGetObjByName ($oIE, "multi_action_form")
    $oCheck = _IEFormElementGetObjByName ($oForm, "dest_cat_ids[]")

    If $oCheck.Value = 356 Then $oCheck.Checked = True
    
EndFunc


Func _KategorienAuswahl()

    $oForm = _IEFormElementGetObjByName ($oIE, "multi_action_form")
    $oCheck = _IEFormElementGetObjByName ($oForm, "dest_cat_ids[]")


        If String($oCheck.value) = "356" Then
        _IEAction($oCheck, "click")
        EndIf

EndFunc


Func _KategorienAuswahl()

    $oForm = _IEFormElementGetObjByName ($oIE, "multi_action_form")
    $oCheck = _IEFormElementGetObjByName ($oForm, "dest_cat_ids[]")


        If ($oCheck.value) = 356 Then
        _IEAction($oCheck, "click")
        EndIf

EndFunc


Func _KategorienAuswahl()

  $oChecks = _IETagnameGetCollection($oIE, "input")
  For $oCheck in $oChecks
      If String($oCheck.value) = "356" Then
          _IEAction($oCheck, "click")
          ExitLoop
      EndIf
  Next

EndFunc

Func _KategorienAuswahl()

  $oChecks = _IETagnameGetCollection($oIE, "input")
  For $oCheck in $oChecks
      If ($oCheck.value) = 356 Then
          _IEAction($oCheck, "click")
          ExitLoop
      EndIf
  Next

EndFunc


Func _KategorienAuswahl()

Local $oInputs = _IETagNameGetCollection($oIE, "input")
If IsObj($oInputs) Then
    For $oInput In $oInputs
        If $oInput.ClassName = "ChkBox" Then
            If $oInput.Value = 356 Then $oInput.Checked = True
        EndIf
    Next
EndIf

EndFunc


Func _KategorienAuswahl()
    
Local $oTable = _IETagNameGetCollection ($oIE, "table")
If String($oTable.className) = "infoBoxContent" Then


        Local $oInputs = _IETagNameGetCollection($oIE, "input")
        If IsObj($oInputs) Then
            For $oInput In $oInputs

                If $oInput.ClassName = "chkBox" Then
                    If $oInput.Value = 356 Then $oInput.Checked = True
                EndIf
            Next
        EndIf

EndIf

EndFunc

 

None of those seem to be working and I have absolutely no Idea what else to do. 

Link to comment
Share on other sites

Okay I made it with this : 

Func _KategorienAuswahl()

Local $oInputs = _IETagNameGetCollection($oIE, "input")
If IsObj($oInputs) Then
    For $oInput In $oInputs
        If $oInput.ClassName = "ChkBox" Then
            If $oInput.Value = 356 Then _IEAction($oInput, "click")
        EndIf
    Next
EndIf


EndFunc

 

My problem was, that I didn't put an _IELoadWait in the func which called _KategorienAuswahl() !

 

It was so simple... thanks for all of your help!

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...