Tag Archive for fields

MOOTOOLS JS – Clear input field onClick onFocus on click focus active

// 201004291250 - Mootools clear input on focus, return default value if no data entered
// FROM:  Clear text field with mootools on focus. - MooTools Users | Google Groups <a href="http://bit.ly/cHPev3" >http://bit.ly/cHPev3</a>

/* 
	I've got this snippet that will clear the value on focus and if the value of 
	the focus is '' it will put the default value again in the input. You will 
	need the default value to be on an attribute of the input, like alt or 
	anyother (if you don't bother about validation). 
	
	Fábio Miranda Costa 
	Engenheiro de Computação 
	<a href="http://meiocodigo.com" >http://meiocodigo.com</a> 

*/

// FUNCTION: 

Element.implement({ 
    clearFocusResetBlur: function(attr){ 
        var valueString = this.get(attr); 
        this.addEvents({ 
            'focus': function(){ 
                if( this.get('value') == valueString ) this.set('value',''); 
            }, 
            'blur': function(){ 
                if( this.get('value') == "" ) this.set('value',valueString); 
            } 
        }); 
    } 
}); 


// Usage
// HTML: 
// <input id="input_id" value="some value" alt="default value" /> 


// JS: 
$('.jform form .cleardefault').set('alt','value').clearFocusResetBlur('alt');

source

Campos de un sObject en Salesforce

Map<String,Schema.SObjectField> mapaCampos = Schema.SObjectType.sObjectACAMBIAR.fields.getMap(); 
List<String> listaCampos = new List<String>(); 
for(String campo : mapaCampos.keyset()){
	listaCampos.add(mapaCampos.get(campo).getDescribe().getName());
}
listaCampos.sort();
String stringADevolver = '';
for(String item : listaCampos){
	if(item != 'TotalPrice'){
		if(stringADevolver.length() > 1)
			stringADevolver += ',';
		stringADevolver += '' + item + '';
	}
}
system.debug(stringADevolver);

source

Use Custom Fields in WordPress

<?php $thereisimage = get_post_meta($post->ID, image, true);
if($thereisimage){ ?>
	<a href="<?php the_permalink() ?>"><img src="<?php echo get_post_meta($post->ID, image, true); ?>" alt="Image" /></a>
<?php }else{ ?>
	<a href="<?php the_permalink() ?>"><img src="images/default.png" alt="Default Image" /></a>
<?php } ?>

source

Custom Fields for HTML Post Titles

1. Enter title without HTML

2. Create a custom field for the title with HTML

3. Output custom field on pages you want the HTML


For example, on the single.php page where you would have used

<h1><php the_title(); ?></h1>
Now you use

<?php

   $html_title = get_post_meta($post->ID, "HTML_title", true);

   if ($html_title) { ?>
                
      <h1><?php echo $html_title; ?></h1>
                
   <?php } else { ?>
                
      <h1><?php the_title(); ?></h1>
                    
<?php } ?>

This checks and sees if that custom field is set. If it is, it outputs that. If not, it uses the regular function.

Because the RSS templates use the regular the_title() function, your titles are same from being weirdified in feed readers.

source

WordPress Custom Fields

Von anderer Page-ID
<?php echo get_post_meta(78, "test", true); ?>  

Von eiger Seite:
<?php echo get_post_meta($post->ID, "test", true); ?>

source

Call Custom Field Values (WordPress)

<?php $customField = get_post_custom_values("page_blurb");
if (isset($customField[0])) {
echo $customField[0];
}
?>

source

Object Runtime Fields Evaluator

/**
* Usage:
* var o={a:1, b:'!! 1+1', c:'!! alert('c')'};
* evalObj(o);
* //o.a===1
* //o.b===2
* //o.c() will display an alert
*
* Updated to keep the scope, usage:
* var o={a:1, b:'!! this.a+1', c:'!! alert(this.b+1)'};
* evalObj.call(o,o);
* //o.a===1
* //o.b===2
* //o.c() will display an alert with 3
*
*/

function evalObj(o,rec){
if (rec === undefined) {
rec=true;
}
for (var name in o){
var elem=o[name];
if (elem){
var telem=typeof elem;
if (telem==='string' && /^!!/.test(elem)){
o[name]=new Function('return '+elem.substr(2)).call(this);
}else if (rec && telem==='object'){
evalObj.call(this,elem,rec);
}
}
}
return o;
}

source

Awk Script to count # of occurences of fields in a file

#!/bin/awk -f

BEGIN {
FieldName[""] = 0; #init in case there are no fields
}

{
FieldName[$3]++; #replace #3 with whatever field you want to count
}

END {
for (i in FieldName) {
if (i != "") { #skip the initialized value
print FieldName[i], i;
}
}
}

source

Sticky Form Fields

$name = $_POST['name'];
$gender = $_POST['gender'];
$howlong = $_POST['howlong'];

****************

function sticky($field) {
if(isset($field))
return $field;
}
function stickyradio($name,$value) {
if ($name == $value) {
return ' checked="checked" ';
}
}

function stickymenu($name,$value) {
if ($name == $value) {
return ' selected="selected" ';
}
}

***************

<input type="text" name="name" value="'.sticky($name).'" />
<input type="radio" name="gender"'.stickyradio($gender,'male').'value="male" />
<option value="1y"'.stickymenu($howlong,'1y').'>1 year</option>

source

Related Entries Forwards

global $DB;

$rel_weblog_id = '4';
$rel_field_value = '{rel_field}';

$sql = "
SELECT *
FROM exp_relationships
LEFT JOIN exp_weblog_data, exp_weblog_titles
ON (
exp_weblog_data.entry_id = exp_relationships.rel_child_id
AND exp_weblog_titles.entry_id = exp_relationships.rel_child_id
)
WHERE exp_relationships.rel_id = '$rel_field_value'
AND exp_weblog_titles.weblog_id = '$rel_weblog_id'
";

// Query for rel_child_id in the exp_relationships table
$rel_data_query = $DB->query($sql);

if($rel_data_query->num_rows > 0)
{
foreach($rel_entry_query->result as $row)
{
$entry_id = $row['entry_id'];
$title = $row['title'];
}
}

source