hi all,
Im doing in-house project ... Im creating form which has a drop down box for gender.... and also a document which contains "he/she" type... when i select the male option in that dropdown box the doc which contains "he/she" should autopopulate to its corresponding gender and generate it into a document.... please help me...

9 Years
Discussion Span
Last Post by kireol

The most simplest approach to do this would be to submit a form and have php do the replace for you using http://us3.php.net/preg_replace

using jquery/ajax would make it nice with no form submission, but that might be a bit above your level.


You don't need PHP to do this! All you need is some JavaScript:

<title>Gender  Drop Down Test</title>
<script type="text/javascript">
function selectGender(value, id){document.getElementById(id).value=value;}
I'm a 
<select name='gender' id='malefemale' onChange="selectGender(this.value, 'heshe');">
  <option value='0'>Male</option>
  <option value='1'>Female</option>
</select>.<br />
<select name='gender' id='heshe' onChange="selectGender(this.value, 'malefemale')">
  <option value='0'>He</option>
  <option value='1'>She</option>
 wrote this paragraph.</p>

that's not really what the OP was asking for.

Also, if you truly wanted to do it in javascript, you could easily perform this with JQuery, but since they asked in the PHP forum, use my post above.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.