0

i have this javascript variable

<script>var onclick_url_bid_o_matic = $(this).parent().find('.do_bid').data('urll');</script>

and this html button

 <a style="cursor:pointer;" class="bido blu" onclick="+onclick_url_bid_o_matic+" id="btn-bidoo">Activate</a>

the javascript variable points to this:

data-urll="<?php
     if($whim_available >= 1)
   {
       if($details['reward_type']=="play_to_win")
         {

    echo '$.auctions.bid(' .$details['id']  . ', $(this), event);';
         }
        if($details['reward_type']=="whim_it_now")
         {

        echo '$.auctions.claim(' . $details['id']  . ', $(this), event);';
          }

          }
 else
{
    echo "$.auctions.alert('You do not have sufficient Loots');";
      }
    ?>"

but the button's onclick doesnt work. and i believe i am not passing the javascript variable right. any help?

2
  • onclick="+onclick_url_bid_o_matic+" what are those + signs Commented Nov 18, 2015 at 11:30
  • 1
    i might be wrong with these. i used them to add the variable (or concatinate if u will) Commented Nov 18, 2015 at 11:31

1 Answer 1

2

Create a javascript function:

function setVariable(){
    var onclick_url_bid_o_matic = $(this).parent().find('.do_bid').data('urll');
}

And call that function in your onClick like so:

<a style="cursor:pointer;" class="bido blu" onclick="setVariable()" id="btn-bidoo">Activate</a>

To test if the variable holds the value needed and that the funtion correctly executed, put it to the console:

console.log("Activate link clicked: " + onclick_url_bid_o_matic);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.