Created
December 12, 2008 23:37
-
-
Save postpostmodern/35340 to your computer and use it in GitHub Desktop.
unform is a function for replacing form controls with plain text using jQuery
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Replaces form controls with plain text | |
function unform(form_class) | |
{ | |
$('form.'+form_class+' input[type=text]').each( | |
function() { | |
$(this).after('<span class="proxy">' + $(this).attr('value') + '</span>'); | |
$(this).hide(); | |
} | |
).next().click( | |
function() { | |
$(this).prev().show(); | |
$(this).hide(); | |
$('form.' + form_class + ' .submit').show(); | |
} | |
); | |
$('form.'+form_class+' textarea').each( | |
function() { | |
$(this).after('<span class="proxy">' + $(this).html() + '</span>'); | |
$(this).hide(); | |
} | |
).next().click( | |
function() { | |
$(this).prev().show(); | |
$(this).hide(); | |
$('form.' + form_class + ' .submit').show(); | |
} | |
); | |
$('form.'+form_class+' select').each( | |
function() { | |
var the_value = $(this).attr('value'); | |
$(this).after('<span class="proxy">' + $(this).find('option[value=' + the_value + ']').html() + '</span>'); | |
$(this).hide(); | |
} | |
).next().click( | |
function() { | |
$(this).prev().show(); | |
$(this).hide(); | |
$('form.' + form_class + ' .submit').show(); | |
} | |
); | |
$('form.' + form_class + ' .submit').hide(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment