Forums

dropdown + button

zingeonaut 08 Jul, 2013
Hi I´m haven´t been able to do this: i have a form with a custom dropdown which is loading elements from a DB. I also have a button that also loads a small iframe with elements from a db. They´re currently working separately, but i need to send a parameter from the dropdown to the button.
<div class='multiline_add'>
  <a class=\"jcepopup\" href=\"chronoform=listSpecific-3&id_province=3&id_ch={$i}\" rel=\"{handler:'iframe'}\"> <input type='button' name='select_{$j}' id='select_{$j}' value='...' /> </a>
</div>


As you can see i have this button that opens a form sending a parameter id_province, but i would love to change dinamically, using the aforementioned dropdown. Thanks
GreyHead 08 Jul, 2013
Hi zingeonaut,

What exactly do you need to do? If you send the parameter before the form loads you can add ti to the url for the modal window. (Add a Debugger to see where the value is available.) If you need to do it in the browser then you would need to add the JavaScript to change the URL.

Bob
zingeonaut 08 Jul, 2013
Both the dropdown and the button are in the same form, and i need to change it. I'm using the following


window.addEvent('domready', function() {
  $('province_aw').addEvent('change', function() {

    var index = this.options[this.selectedIndex].value;
(the rest of the code is not relevant)


to get the value of the selected index but i cant put within the link i'm sending to the iform
Thanks
GreyHead 09 Jul, 2013
Hi zingeonaut,

If the url for the modal window is in the same page then you can almost certainly locate and change it with JavaScript. If you need help with how to do that you might find it at StackOverFlow.com

Bob
zingeonaut 09 Jul, 2013
I changed the approach, following your advice and got here


window.addEvent('domready', function() {
  $('link1').addEvent('click', function() {
    var e = document.getElementById('province_aw');
    var index= Number(e.options[e.selectedIndex].value);
    var b = document.getElementById("choice_2").value;
var link  = "index.php?option=com_chronoforms&chronoform=listSpecific-3&id_province="+index+"&id_ch="+b;
    
    //var a = document.getElementById("link1");
    //a.setAttribute("href", link);

    //document.getElementById('link1').href = link;
    this.href = link;
  });
});


I tried everything (even what it's commented, to no use

the actual code for the link would be

  <a class="jcepopup" id="link1" rel="{handler:'iframe'}"> <input type='button' name='prueba' id='prueba' value='...' /> </a>
GreyHead 10 Jul, 2013
Hi zingeonaut,

Then I'm afraid that you will need help from someone who can help you with this :-(

Bob
zingeonaut 15 Jul, 2013
I've come to a stall with this. I managed to get the button changing the href using the following code

document.getElementById('link1').href = "index.php?option=com_chronoforms&chronoform=listSpecific-3&id_province="+index+"&id_ch="+b;


Then when i click the button it only opens a blank iframe. However, if a right - click the button and select "open link in a new tab" it will work perfectly.
This topic is locked and no more replies can be posted.