patheticsam Posted January 10, 2009 Share Posted January 10, 2009 Hi! I'm not really good in PHP and I have a problem. I tried many different way to solve it but none of them worked. In the first part I'm taking out some stuff of mySQL database and fetch it into a multiple select box Here's the code : <select name="fields" size=5 multiple> <?php $db = mysql_connect('localhost', 'database', 'password'); mysql_select_db('databasename',$db); $sql = "SELECT `firstname`, `lastname`, `field3`, FROM table1"; $rs = mysql_query($sql); while($row = mysql_fetch_array($rs)) { echo "<option value=\"".$row['field3']."\">".$row['field1']." ".$row['field2']."\n "; } echo " </select> "; After that I have 3 radio buttons that will change the content of a "textarea" depending on which radio button is selected. Until now everything works fine.... Here's the code : echo " <script type=\"text/javascript\"> function updateText(src) { if(src.checked) document.getElementById('email').value = src.value; } </script> And now the problem..... let's say I selected the first radion button. What I want to do is I want the text 1 to appear but with the firstname depending on which firstname I have selected in the multiple select box... <input type='radio' value='email text 1 looks like blah blah blah firstname blah blah ' onClick='updateText(this);' name='text'/>Option 1 <input type='radio' value='email text 2' onClick='updateText(this);' name='text'/>Option 2<input type='radio' value='email text 3' onClick='updateText(this);' name='text'/>Option 3 <br> <textarea cols=78 rows=15 id='email'></textarea> <input type=submit value=send> "; ?> I don't know if anyone can help me out....But it would be really appreciated....Thank you!!!! Link to comment https://forums.phpfreaks.com/topic/140328-need-help-with-php-script-and-variables/ Share on other sites More sharing options...
Twister1004 Posted January 10, 2009 Share Posted January 10, 2009 Where is your error at? Link to comment https://forums.phpfreaks.com/topic/140328-need-help-with-php-script-and-variables/#findComment-734322 Share on other sites More sharing options...
patheticsam Posted January 10, 2009 Author Share Posted January 10, 2009 I want to select the senders firstname via the multiple selectbox and after that I choose the template of the e-mail..I want the e-mail with the firstname I selected in the selectbox Link to comment https://forums.phpfreaks.com/topic/140328-need-help-with-php-script-and-variables/#findComment-734323 Share on other sites More sharing options...
patheticsam Posted January 10, 2009 Author Share Posted January 10, 2009 I can't define the variable depending on what's selected in the multiple select box.... Link to comment https://forums.phpfreaks.com/topic/140328-need-help-with-php-script-and-variables/#findComment-734325 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.