glenelkins Posted July 8, 2006 Share Posted July 8, 2006 HiNot sure if anyone can help on this hereWhat i want to be able to do, is after the following code had run to generate the drop down list of email history, i want to set some JS so when the user clicks one of the emails in the history, it automatically puts it into a text box. I have an idea of how to do this but not 100%[code]<select name="emailhistory"> <? $sql = "SELECT * FROM email_history WHERE user_id=" . $userid; $result = mysql_query($sql) or die (mysql_error()); while ($emailHistory = mysql_fetch_array($result)) { ?> <option><? echo $emailHistory['email']; ?></option> <? } ?> </select>[/code]here is what i think the JS should look like:[code]<select name="emailhistory" onclick="return ChooseHistoryEmail()"><SCRIPT LANGUAGE="JavaScript"> function ChooseHistoryEmail() { chosenemail = document.formname.emailhistory.option[0]; document.formname.textboxname.value = chosenemail; }</SCRIPT>[/code]any ideas? Quote Link to comment Share on other sites More sharing options...
digitalgod Posted July 8, 2006 Share Posted July 8, 2006 wrong forum, try your luck here http://www.phpfreaks.com/forums/index.php/board,6.0.html ;) Quote Link to comment Share on other sites More sharing options...
Barand Posted July 8, 2006 Share Posted July 8, 2006 try[code]<html><head><meta name="generator" content="PhpED Version 4.5 (Build 4513)"><title>Sample</title><SCRIPT LANGUAGE="JavaScript"> function ChooseHistoryEmail(val) { document.getElementById("textboxname").value = val; }</SCRIPT></head><body><form name="formname" ><select name="emailhistory" onchange="ChooseHistoryEmail(this.value)"> <option value="0">'SELECT-</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> </select><input type="text" name="textboxname" id="textboxname" size="5"><input type="submit" name="submit" value="Submit"></form></body></html>[/code]Moving to JS forum Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.