Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #20817
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!newsfeed.fsmpi.rwth-aachen.de!uucp.gnuu.de!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail |
|---|---|
| Content-Type | text/plain; charset="UTF-8" |
| Message-ID | <5682005.goIip4NAP1@PointedEars.de> (permalink) |
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
| Reply-To | Thomas 'PointedEars' Lahn <usenet@PointedEars.de> |
| Organization | PointedEars Software (PES) |
| Date | Sun, 28 Jul 2013 18:15:09 +0200 |
| User-Agent | KNode/4.10.5 |
| Content-Transfer-Encoding | 8Bit |
| X-Face | %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&.<b';Md8`dH6iqhT)6C^.Px|[=M@7=Ik[_w<%n1Up"LPQNu2m8|L!/3iby{-]A+#YE}Kl{Cw$\U!kD%K}\2jz"QQP6Uqr],./"?;=4v |
| Face | iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEXTxa4RFk5dUWANED8PFEfy7+MGBiW+n3ZNF/QuAAACaElEQVQ4jVXUwVOcMBQG8Dc7Rc4PUntdWV2uxjDpGaGeozOp1woar4jd5t/v9wLstMwsA/ntlxdCAgUc1hjTc9/JCZfGoo3wG3HdmdAWrIJRHe7GM/TmpY5VFefuVcAkkPbLIaN8rmPmjloyZxgyR3GuJ4K0AGtJ2htz8o7yqikm759fldQXaMpbDzjKAG+8v+AugVTOPO5DOjLvGtUYQwh0CPjnVMyGd+8/GfUB5nLKJDD2aLDh5HYyMDJGDwQIo2ZmZcKbowNmAdB/AzyFhrmF2MHRb0QJJfaAnwGB6orZhoykLzJtGwF/xpYxI1dswomiUj3gTuAIqCn/4C7cULwGNBtwMTk3Y4LfKB5YUaOKBKYtpplm7u0vip8tU1NWWyI/7XdcSuIDoMt6rVHMWT0DbjHPGqDqZVSa6zleLcUTcIKLoMv3ueJluALtAo9B302zPPlrtiVScRdCjXvVh3e3JpYa/jjkuC9N+LrBMlz/eAN4eQijX2EdLo6c5tGGHwLyHFtXk89dDGHwCVhG9T0S/j55AhRZgkMCmUQXJ49TnS1wnQDvw0eAh9ICeMmEFbCnPMFzjAvsWoEWEFdYEx+S0MoUZ1gT1wId8+AF3Bl2OoEu906AUHx5VLw/gXYg/x84loOah/2UYNrgiwSwGO7RfUzVBbx/kgpckumGOi6QirtD6gkLTitbnxNol47S2jVc2vsN5kPqaAHT8uUdAJM4v/DanjYOwmUjWznGfwB7sGtAtor5BgofDuzaRj4kSQAqDakTsKORa3Q3xKi3gE1fhl71KRMqrdZ2AWNNg/YOhQyrVBnb+i+nEg4bsDA+egAAAABJRU5ErkJggg== |
| Subject | Re: Script stopped working when I altered form type |
| Newsgroups | comp.lang.javascript |
| References | <dwj9j8e4wvez$.158zrqmvkzmci$.dlg@40tude.net> |
| MIME-Version | 1.0 |
| Lines | 87 |
| NNTP-Posting-Date | 28 Jul 2013 18:15:11 CEST |
| NNTP-Posting-Host | 35d7a0d0.newsspool2.arcor-online.net |
| X-Trace | DXC=BToDGG80eGg;iVb[J9ZZP`A9EHlD;3Ycb4Fo<]lROoRa8kF<OcfhCOk9oB1OC=45TlDZm8W4\YJNloX_D\4=WNdl97X>9fC[KCe`cf388o2NQe |
| X-Complaints-To | usenet-abuse@arcor.de |
| Xref | csiph.com comp.lang.javascript:20817 |
Show key headers only | View raw
Mad Hatter wrote:
^^^^^^^^^^
Please get a real name.
> First off I'm absolutely useless at javascript.
Good, because there is no such programming language:
<http://PointedEars.de/es-matrix>
> I like playing around with PHP. I had a working PHP script which had a
> form which included a text box. I used the following script which I found
> somewhere on the net a long time ago to insert text depending on what
> button was pressed:-
>
> <SCRIPT LANGUAGE='JavaScript'>
> <!--
> function insertcode(newcode) {
> document.newtopic.msg.value = document.newtopic.msg.value+newcode;
>
> }
> //-->
> </SCRIPT>
Always validate your generated markup: <http://validator.w3.org/>
And the proper syntax is:
<script type="text/javascript">
function insertcode (newcode)
{
document.forms["newtopic"].elements["msg"].value += newcode;
return false;
}
</script>
> and an assortment of buttons along the lines of :-
> <a href="javascript:insertcode('[i]TEXT[/i] ')"><img src="b2.jpg"
> height="15" alt="Italic" border="0" /></a>
<a href="#" onclick="return insertcode('[i]TEXT[/i] ')"
><img src="b2.jpg" height="15" alt="Italic" border="0"></a>
There are even better ways, of course. Consider generated “button”
elements, where no navigation will take place when there is insufficient
client-side script support (as the buttons will not be generated then in the
first place).
> This worked fine when the form was the following type :-
>
> <form action="ep.php" method="POST" name="newtopic">
>
> I've just had to alter the form type to include file uploads so forms are
> now :-
> <form ENCTYPE='multipart/form-data' action='ep.php' method='POST'
> name='newtopic'>
>
> The text input box hasn't altered :-
It should have been.
> <textarea rows="10" cols="50" name="msg" wrap="virtual"><?php echo
> "$reply"; ?></textarea>
Variable expansion is pointless there. What is missing is escaping of
output to prevent code injection:
<textarea rows="10" cols="50" name="msg" wrap="virtual"><?php
echo htmlspecialchars($reply);
?></textarea>
> Since I've altered to the ENCTYPE='multipart/form-data' form input my
> buttons no longer work. Nothing at all. Can anyone tell me why and suggest
> a fix please.
Adding the “enctype” attribute alone does not cause this problem. There is
relevant code that you are not showing. Please post the public URL of a
reduced testcase.
<http://jibbering.com/faq/#posting>
<http://PointedEars.de/faq#posting>
--
PointedEars
Twitter: @PointedEars2
Please do not Cc: me. / Bitte keine Kopien per E-Mail.
Back to comp.lang.javascript | Previous | Next — Previous in thread | Find similar | Unroll thread
Script stopped working when I altered form type Mad Hatter <colin@class31.co.uk> - 2013-07-27 15:22 +0100
Re: Script stopped working when I altered form type "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2013-07-27 17:13 +0200
Re: Script stopped working when I altered form type Mad Hatter <colin@class31.co.uk> - 2013-07-27 17:35 +0100
Re: Script stopped working when I altered form type "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2013-07-27 23:54 +0200
Re: Script stopped working when I altered form type Mad Hatter <colin@class31.co.uk> - 2013-07-28 22:32 +0100
Re: Script stopped working when I altered form type Eric Bednarz <bednarz@fahr-zur-hoelle.org> - 2013-07-29 00:56 +0200
Re: Script stopped working when I altered form type Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-07-28 18:15 +0200
csiph-web