473,836 Members | 1,602 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Putting a user input in a textarea onload

Hey
Im making a homepage in php. I use a html form to put data into mysql
and i want to make some buttons which inserts user input values into a
textarea. I have used a button like this:

<input type="button" value="Add Quote"
onclick="docume nt.getElementBy Id('nyhed').val ue+=''">

The button works fine and insterts into the textarea.
Although I want to make a button which onclick asks the user for a
input and inserts it into the textarea. The script would in this case
ask for an input and insert
USER INPUT
into the
textarea.

Does someone know how to do that?

Apr 24 '06 #1
2 9672
da************* ***@gmail.com said on 24/04/2006 5:06 PM AEST:
Hey
Im making a homepage in php. I use a html form to put data into mysql
and i want to make some buttons which inserts user input values into a
textarea. I have used a button like this:

<input type="button" value="Add Quote"
onclick="docume nt.getElementBy Id('nyhed').val ue+=''">

The button works fine and insterts into the textarea.
Although I want to make a button which onclick asks the user for a
input and inserts it into the textarea. The script would in this case
ask for an input and insert
USER INPUT
into the
textarea.


Why not let the user enter whatever into the textarea and add the quote
tags when you get the response at the server?

You can use a prompt to get user input, but it's rather kludgy to use a
dialog to get input that is dropped into a page anyway (I hate such things).

<textarea onclick="
this.value = '[quote]'
+ prompt('Enter some text')
+ '[quote]';
"></textarea>
But no recommended.
--
Rob
Group FAQ: <URL:http://www.jibbering.c om/FAQ>
Apr 24 '06 #2
RobG wrote:
da************* ***@gmail.com said on 24/04/2006 5:06 PM AEST:
Im making a homepage in php. I use a html form to put data into mysql
and i want to make some buttons which inserts user input values into a ^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^ textarea. I have used a button like this:

<input type="button" value="Add Quote"
onclick="docume nt.getElementBy Id('nyhed').val ue+=''"> ^^^^^^^^^^^^^^^ The button works fine and insterts into the textarea.
Although I want to make a button which onclick asks the user for a
input and inserts it into the textarea. The script would in this case
ask for an input and insert
USER INPUT
into the
textarea.
Why not let the user enter whatever into the textarea and add the quote
tags when you get the response at the server?


I think you miss the point :)

Obviously, this is for some kind of bulletin board or Wiki, where
the "
...
" markup is to indicate text quoted from the
precursor or a third source. (Have you never used such before? ;-))
You can use a prompt to get user input, but it's rather kludgy to use a
dialog to get input that is dropped into a page anyway (I hate such
things).

<textarea onclick="
this.value = '[quote]'
+ prompt('Enter some text')
+ '[quote]';
"></textarea>
Since prompt() returns `false' if the user cancels, one wants to enhance
this a bit at least (watch for word-wrap):

<textarea
onclick="var s; this.value = '[quote]' + ((s = prompt('Enter some
text')) ? s : "") + '[quote]';"</textarea> But no recommended.


True. Newline in attribute values is not recommended. And one should use
a button instead, as the OP already did (only his referencing was
unnecessarily complicated and error-prone). That way the button could be
generated by script (so that without script, users do not have to worry
about a dysfunctional button) and could facilitate for inserting the markup
at the cursor position, or replace the current selection. Quick hack for
Geckos:

<meta http-equiv="Content-Script-Type" content="text/javascript">
...
<form ...>
...
<script type="text/javascript">
function addQuote(o)
{
// if nothing is selected, selStart == selEnd
var
selStart = o.selectionStar t,
selEnd = o.selectionEnd,
s;

if ((s = window.prompt(' Enter some text'))
{
oSel.value = oSel.value.subs tring(0, selStart)
+ '
' + s + '
'
+ oSel.value.subs tr(selEnd);
}
}

document.write( '<input type="button"'
+ ' value="Add Quote"'
+ ' onclick="addQuo te(this.form.el ements[\'nyhed\']);">');
</script>

<textarea name="nyhed" ...></textarea>

...
</form>

See <URL:http://faqts.com/knowledge_base/view.phtml/aid/17749/fid/53> (or
Wikimedia etc. source code) for (a hint towards) a cross-browser approach.
PointedEars
Apr 24 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
8248
by: hokiegal99 | last post by:
I don't understand how to use a loop to keep track of user input. Could someone show me how to do what the program below does with a loop? Thnaks! ---------------------------- #Write a program that reads 10 numbers from the user and prints out the sum of those numbers. num0 = input("Enter a number: ")
3
3442
by: N?ant Humain | last post by:
I have just begun learning Python so that I can write a simple script to make modification of a file used by another Python script easier. This file is basically a list of regular expressions. What I want to do is allow the user to select one of these regular expressions to modify, but I've realized I know of no way to provide a default value for user input. I could choose to show the regular expression the user has chosen and simply allow...
3
16942
by: Clare | last post by:
Hi I have a report that is made of 4 subreports. There is no actual information in the main report, and the record source is empty. In the Header section of the main report, I have a text box and I want some user input to go in there every time the report is run. I'm putting = into the control source but it comes up as #Name? when I run the report. If I put something in the record source for the main form, the text
17
7934
by: comp.lang.tcl | last post by:
The TCL command I am using will do a command-line action on a PHP script: set cannotRunPHP I have to do it this way as both the TCL script and the PHP script run as CLI. However, "info.php" requires user input to run; this causes the TCL script calling the PHP script to hose up and die. Is there a way I can do this so that the TCL script can call the PHP
3
3707
by: dei3cmix | last post by:
Hey, I am having a problem with a program I am working on. Basically, the first part of the program gets input from a file using cin.getline. Then the second part, (still in the same main as the first part) needs to get input from the user, and I want to do this with cin.getline also. The problem I am getting, is when I run the program, the text if read in from the file correctly, but it seems to just skip over the cin.getline when I want...
9
5850
by: chuck | last post by:
I need some help with validating user input. I am writing a C computer program for an intro to C course. Here is the situation. I am creating an application that will do currency conversions. The user will be presented with a list of 5 selections they can make. They will then be prompted for which selection they want to enter (which can only be 1-5, no characters or anything like it). Once they select the number, 1 for Euro, 2 for...
2
2879
by: Matt | last post by:
Hi, I'm ridiculously new to Access (about a week!) so please be patient! My database is a record of British Standards. Each has a unique identifier. Some are split into parts. I would like the user to be able to input the data into a single textbox using a form like this: Record1: BS 1490-1 Record2: BS 1490-2
2
1952
by: niskin | last post by:
I'm trying to create a file called retrieve.vbs with my program and it creates this file, with all the necessary code for the file to run, but the part that relies on user input does not get written properly. In my program the user inputs the name of the computer they want to connect to and I need to use that variable in my script. The name of the computer I trying to connect to when I test my program is ADMIN-PC. Once my program has created the...
12
2096
by: Tarique | last post by:
I have tried to restrict the no. of columns in a line oriented user input.Can anyone please point out potential flaws in this method? btw.. 1.I have not used dynamic memory allocation because thats not something i want to implement. 2.I suppose my input line oriented . 3.The maximum columns i need is 80 4.There is an infinite loop in the program :) 5.I have *not* tried to validate the data as yet.
0
9825
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10560
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10260
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7795
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6984
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5829
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4023
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3116
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.