I am trying to expand an existing form within PHPmyDirectory, and what I need to do is use the information entered earlier in the form to autopopulate some fields further down so re-entering data is not required.
For example: a "stage Name" field is automatically populated with a combination of the First nd Last Name Initial unless something specific is needed instead.
This code:
$form->addField('last_name','text',array('label'=>'Last Name','fieldset'=>'listing',
'onblur'=>'$.ajax({data:({action:\'rewrite\',text:$(\'#first_name\').val()+ \' \'
+$(\'#last_name\').val().substring(0,1)}),success:function(text_rewrite)
{$(\'#stage_name\').val(text_rewrite)}});'));
generates:
mary-l
onblur in the Stage Name field if someone has typed Mary Lambert in the first_name/last_name fields above
which is almost great - but I need it to simply generate: Mary L (no hyphen, no lowercase)
I'm picking this code up from a field which generates a friendly URL so I imagine that's why I'm getting lowercase and hyphens, I just can't figure out what is generating that formatting.
I've looked around quite a bit - I assume the '/rewrite'/ is doing it, but I can't find anywhere in the site code that assigns a function to '/rewrite'/ so is that a standard js command? And if so, is there another I should use in its place to get the output formatting I need?
Can anyone point me in the write direction for outputting a string that keeps the capitalization and gives me white space where I get hyphens now?
Thanks very much. This is probably a really obvious question, so sorry.