PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

onChange JavaScript

  1. kiwii
    Member

    Hi, I need to put this code inside a normal input.

    onchange="document.getElementById("dColor").style.backgroundColor = '#' + this.color"

    How do I do this?
    Thanks

    Posted 12 years ago on Thursday March 22, 2012 | Permalink
  2. kiwii
    Member

    Any?

    Posted 12 years ago on Friday March 23, 2012 | Permalink
  3. You would need to view the source, get the input ID and then plug that into your script so it would know what it's supposed to change. You would place your script in your theme's header.php file wherever your particular theme recommends you to place custom script blocks.

    Posted 12 years ago on Saturday March 24, 2012 | Permalink
  4. kiwii
    Member

    Hi Kevin, thanks for the response. The ONCHANGE event its supposed to happend inside a input text, here is the example:

    <input id="txtColor" class="color" onchange="document.getElementById("dColor").style.backgroundColor = '#' + this.color" >

    Posted 12 years ago on Saturday March 24, 2012 | Permalink
  5. kiwii
    Member

    How can I achieve this?

    Posted 12 years ago on Saturday March 24, 2012 | Permalink
  6. You would need to use this filter to modify the input.

    http://www.gravityhelp.com/documentation/page/Gform_field_input

    Posted 12 years ago on Saturday March 24, 2012 | Permalink
  7. kiwii
    Member

    Hi Kevin, thank you for the quick response. I would really appreciate you If you can give me the actual code for this. I read the link you pass me, but I'm not good programming.

    I know you shouldn't do this for me, but could you exception this time?

    The name of the input is: input_3_9 and what i need to insert this input is onchange="document.getElementById("dColor").style.backgroundColor = '#' + this.color"

    Thanks mate.

    Posted 12 years ago on Saturday March 24, 2012 | Permalink
  8. Place this class name on the field in question: change_class

    Then use this:

    <?php
    add_action("gform_field_input", "map_input", 10, 5);
    function map_input($input, $field, $value, $lead_id, $form_id){
        if($field["cssClass"] == "change_class"){
            $input = '<input id="txtColor" class="color" onchange="document.getElementById("dColor").style.backgroundColor = "#" + this.color" >';
        }
        return $input;
    }
    ?>
    Posted 12 years ago on Sunday March 25, 2012 | Permalink
  9. kiwii
    Member

    Thanks

    Posted 12 years ago on Friday March 30, 2012 | Permalink