Title: term_exists not working in Javascript
Last modified: August 20, 2016

---

# term_exists not working in Javascript

 *  Resolved [iyamdman](https://wordpress.org/support/users/iyamdman/)
 * (@iyamdman)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/term_exists-not-working-in-javascript/)
 * I finally got my back-end to create the wheel codes from the checked taxonomies
   in the add custom post admin area.
 * Now, I want to add that tire code to the wheel_type taxonomy.
 * The below code ran great, until I added the if statement under //Add code to 
   Taxonomy
 * Now nothing is working, but I get nothing in the error console.
 * I figure it must be a stupid syntax mistake – can anyone help me out?
 * Or am I missing something else?
 *     ```
       jQuery('#replace').click(function(){
        		//get tire code and name
        		var code = jQuery('input[name="tire_code"]').val();
        		var name = jQuery('input[name="tire_name"]').val();
        		var bname = jQuery('input[name="tire_bname"]').val();
   
        		         alert(code + " + " + name + " + " + bname);
   
        		//get tire brand
        		var tirebran = jQuery('#tire_brandchecklist').find(":checked").parent('label').text();
        		tirebran = jQuery.trim( tirebran );
   
                       //Add code to Taxonomy
   
                       if( term_exists( code, wheel_type ){
        		     continue;
                            }
        	        else
        		     {
                            wp_insert_term( code, wheel_type );
                            }
   
        		//update title
        		var title = code + ' : ' + name + ' tires';
        		if(tirebran!=''){
        			title += ' with ' + bname + ' letters';
        		}
        		jQuery('input[name="post_title"]').focus().val(title);
        	});
        	//-->
       	</script>
       ```
   

The topic ‘term_exists not working in Javascript’ is closed to new replies.

## Tags

 * [javascript](https://wordpress.org/support/topic-tag/javascript/)
 * [term_exists](https://wordpress.org/support/topic-tag/term_exists/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [iyamdman](https://wordpress.org/support/users/iyamdman/)
 * Last activity: [14 years, 6 months ago](https://wordpress.org/support/topic/term_exists-not-working-in-javascript/)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
