Sunday, 15 January 2012

javascript - Dynamic PHP Code For Inputting User Info -



javascript - Dynamic PHP Code For Inputting User Info -

i'm working on php form inputting user information. have these 3 of import fields: first name, lastly name, , e-mail. need set e-mail automatically when user enters first 2 fields , before saving. illustration when user types 'first' in first name , 'last' in lastly name fields, e-mail field should automatically show first.last@example.com.

the code written , part i'm working on:

echo '<table ><tr><td >'.textinput($student['first_name'],'students[first_name]','<font color=red>'._('first').'</font>','size=12 class=cell_floating maxlength=50 style="font-size:14px; font-weight:bold;"').'</td><td>'.textinput($student['middle_name'],'students[middle_name]',''._('middle').'','class=cell_floating maxlength=50 style="font-size:14px; font-weight:bold;"').'</td><td>'.textinput($student['last_name'],'students[last_name]','<font color=red>'._('last').'</font>','size=12 class=cell_floating maxlength=50 style="font-size:14px; font-weight:bold;"').'</td><td>'.selectinput($student['name_suffix'],'students[name_suffix]',''._('suffix').'',array('jr.'=>'jr.','sr.'=>'sr.','ii'=>'ii','iii'=>'iii','iv'=>'iv','v'=>'v'),'','style="font-size:14px; font-weight:bold;"').'</td></tr></table>'; else echo '<div id=student_name><div style="font-size:14px; font-weight:bold;" onclick=\'addhtml("<table><tr><td>'.str_replace('"','\"',textinput($student['first_name'],'students[first_name]','','maxlength=50 style="font-size:14px; font-weight:bold;"',false)).'</td><td>'.str_replace('"','\"',textinput($student['middle_name'],'students[middle_name]','','size=3 maxlength=50 style="font-size:14px; font-weight:bold;"',false)).'</td><td>'.str_replace('"','\"',textinput($student['last_name'],'students[last_name]','','maxlength=50 style="font-size:14px; font-weight:bold;"',false)).'</td><td>'.str_replace('"','\"',selectinput($student['name_suffix'],'students[name_suffix]','',array('jr.'=>'jr.','sr.'=>'sr.','ii'=>'ii','iii'=>'iii','iv'=>'iv','v'=>'v'),'','style="font-size:14px; font-weight:bold;"',false)).'</td></tr></table>","student_name",true);\'>'.$student['first_name'].' '.$student['middle_name'].' '.$student['last_name'].' '.$student['name_suffix'].'</div></div>'; echo'</td></tr>'; echo '<tr><td>'._('email').'</td><td>:</td><td>'.textinput($student['email'],'students[email]','','size=100 class=cell_medium maxlength=100').'</td></tr>';

i don't know how i'm supposed edit or add together jquery code :/ appreciate help, give thanks :)

html

first name : <input type="text" id="firstname" value=""><br /> lastly name : <input type="text" id="lastname" onchange="createemail()"><br /> email : <input type="text" id="email">

javascript

<script> function createemail() { var fn = document.getelementbyid("firstname").value; var ln = document.getelementbyid("lastname").value; document.getelementbyid("email").value = fn+"."+ln+"@example.com"; } </script>

javascript php jquery html

No comments:

Post a Comment