View Full Version : List Boxes and Forms
Thelma
08-07-2002, 07:57 PM
I am trying to make a character which a user has chosen from a listbox appear in a textbox on the same form - it would be useful for inserting foreign characters into words.
I don't know how to make the character appear in the textbox once it has been chosen.
I thought I could refresh the page or use persistence (I'm writing in HTML and PHP just now) or I thought I might be able to simply use HTML, but nothing I am trying works for this, especially when I have characters before and after the character from the listbox.
Any ideas would be welcome, thanks
Zvona
08-08-2002, 11:27 AM
Do you mean something like this :
<!-- Example Written by Zvona -->
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Applying custom characters</title>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1;" />
<style type="text/css">
BODY {font:normal 0.8em verdana,serif;}
INPUT {font:normal 0.8em arial,helveitica;}
</style>
<script type="text/javascript">
<!--
function zApply(oForm)
{
var sChar = oForm.chChar[oForm.chChar.selectedIndex].value;
oForm.tfChar.value += sChar;
}
// -->
</script>
</head>
<body>
<form name="frmChar" action="">
<table>
<tr>
<td>Select a character</td>
<td>
<select name="chChar">
<option value="">-- Select --</option>
<option value="&copy;">&copy;</option>
<option value="&trade;">&trade;</option>
<option value="&reg;">&reg;</option>
</select>
</td>
<td><input id="btnChar" type="button" value="Apply" onclick="zApply(this.form);" /></td>
</tr>
<tr>
<td>Input text here</td>
<td colspan="2"><input id="tfChar" value="" size="20" /></td>
</tr>
</table>
</form>
</body>
</html>
Thelma
08-08-2002, 07:46 PM
Thanks! I got round to trying a bit of Javascript and it wasn't quite working!
I was thinking, though. I want to enter a whole word into the textbox at "Input word here" (with/without special characters), and put a button beside this box to enter the word into a database. But I think that the chChar variable is the only one being read when I try to pass the word because it responds to the "Apply" button first. Is this right and any ideas?
All help appreciated
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.