JavaScript and client side scripting.
Moderator: General Moderators
cbrian
Forum Commoner
Posts: 97 Joined: Sun Feb 27, 2005 12:29 pm
Post
by cbrian » Sun Feb 27, 2005 4:18 pm
What I'm trying to do here is, when you double click on a form select, it inserts '/msg $id' (this is within PHP) into a text form. Here's some snippets from the code. So far, it doesn't work.
Code: Select all
<script language="javascript">
function insert(pusername) {
document.form.message.value = "/msg "
}
</script>
Code: Select all
<form name="form" action="game.php?where=chat" method=POST>
<input name="message" type=text size=40 maxlength=100>
<input type=submit name="submit" value="Chat">
Code: Select all
print("<select size=17 name="people" style="width:150">");
print("<option value="$puserid" ondblclick="insert('$pusername')">$pusername</option>");
print("</select>");
The $puserid and $pusername have been defined already.
Thanks for any help you can give me.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sun Feb 27, 2005 4:41 pm
Code: Select all
<html>
<head>
<script language="Javascript">
function insert(pusername) {
document.formsї'form'].elementsї'message'].value = "/msg " + pusername;
}
</script>
</head>
<body>
<form name="form" action="game.php?where=chat" method="POST">
<input name="message" type="text" size="40" maxlength="100">
<input type=submit name="submit" value="Chat">
<select size="17" name="people">
<option value="10" ondblclick="insert('foo')">foo</option>
<option value="11" ondblclick="insert('bar')">bar</option>
<option value="12" ondblclick="insert('bla')">bla</option>
</select>
</form>
</body>
</html>sure seems to work...
cbrian
Forum Commoner
Posts: 97 Joined: Sun Feb 27, 2005 12:29 pm
Post
by cbrian » Sun Feb 27, 2005 5:21 pm
Doesn't work for me
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sun Feb 27, 2005 5:42 pm
did you copy the code I posted and try it? or just stare at your code some more?
Joe
Forum Regular
Posts: 939 Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow
Post
by Joe » Sun Feb 27, 2005 6:58 pm
What browser are you using and are you sure you have the correct js configurations etc?.
cbrian
Forum Commoner
Posts: 97 Joined: Sun Feb 27, 2005 12:29 pm
Post
by cbrian » Mon Feb 28, 2005 2:44 pm
Feyd: I copied and pasted your code.
Joe: I'm using the latest Internet Explorer and my host does have Javascript.
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098 Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia
Post
by Chris Corbyn » Mon Feb 28, 2005 4:50 pm
Joe: I'm using the latest Internet Explorer and my host does have Javascript.
Huh? Your host does...?? JavaScript runs in your own browser dude, not on the host
Feyd's code works for me in IE6 and Moz Firefox
cbrian
Forum Commoner
Posts: 97 Joined: Sun Feb 27, 2005 12:29 pm
Post
by cbrian » Tue Mar 01, 2005 3:13 pm
Erg. Sorry, I'm very stupid. Still doesn't work for me.