• Hi Guys,
    I have a javascript code that i use in custom fields and its works fine when user selects an image from the dropdown(select) field but when i try to do the same in a custom widget, it does not work. Why the following code does not work?…

    <label for="nda_cf5">nda cf5</label>:<br /><img id="img_nda_cf5" src="" alt="" style="display:none;" /><select name="nda_cf5" id="nda_cf5" class="nda_cf5" size="1"><option value="">- select file -</option><option value="9" jsvalue="https://localhost/random_widget/wp-content/uploads/2013/12/logo-250-150x35.png">logo-250.png</option><option value="8" jsvalue="https://localhost/random_widget/wp-content/uploads/2013/12/mobile-150x150.jpg">mobile.jpg</option></select><script type="text/javascript">
    	jQuery(document).ready(function() {
    		//
    		jQuery('#nda_cf5').change(function () {
    			var getvalue = jQuery('#nda_cf5 :selected').attr('jsvalue');
    			if (getvalue) {
    				jQuery('#img_nda_cf5').attr('src', getvalue);
    				jQuery('#img_nda_cf5').attr('style', 'display:block;');
    			} else {
    				jQuery('#img_nda_cf5').attr('style', 'display:none;');
    			}
    		});
    		//
    	});
    	</script>

    Thanks in advance,

    Najam D.

Viewing 8 replies - 1 through 8 (of 8 total)
Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘javascript working as custom field but not in a custom widget’ is closed to new replies.