Jump to content

PHP & JQUERY


gotornot

Recommended Posts

Hi All (Again)

 

I am looking to pick up variables in jquery from a string created:

 

function search_by() {

var search_term = $('#search_for', $(this).attr('value'));

alert(search_term);

}

 

I cant seem to get the value i am trying to into a "var".

 

This is the code on the page i am using a  onClick="search_by();"

i.e:

<a class="show_cats" search_cat="PDAs & Accessories" search_for="fire" onclick="search_by();" href="#">

 

I am trying to get the value inside the "search_for" field.

Any ideas????

Link to comment
Share on other sites

would that not work properly? i have set a function on the "onClick" area of the <a href>?

It's similar, except my example doesn't require the onclick="" attribute.

 

also, in your code...how is this supposed to work??

var search_term = $('#search_for', $(this).attr('value'));

 

You have no id called 'search_for' and not attribute called 'value'.

search_for //that's your attribute
= fire //That's its value 
$(this).attr('search_for'); //should return the value of the search_for attribute

FYI, this topic belongs in the Javascript Section and please use code tags to display sample code.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.