By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,607 Members | 1,944 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,607 IT Pros & Developers. It's quick & easy.

Javascript - Button that adds text to the end of a form field ??

user404
P: 1
I'm trying to add a button that will update the value of a form field with some text followed by the contents of another field. Here's what I got:

[html]
<form action="<?php echo ($_SERVER['PHP_SELF']); ?>" method="post" name="foo">

{...snip...}

<p>
<b>Item to list on printout:</b>
<input type="text" name="item" size=40 maxlength=80 /></p>
<p><input type="checkbox" name="fl" value="1" CHECKED />
Your order is currently
<input type="text" name="status" size="30" maxlength="60" value="backordered" style="background-color:#ebecfe" />

<input type="button" name="bar" value="Held up waiting on" onClick="document.foo.status.value='held up waiting on' " />

[/html]

I'd like the msg on line 12 to be: 'held up waiting on' . document.foo.item.value
but I don't know how to do that in javascript in a onClick setting.

Thanks in advance,

- Dave (user404)
Jun 18 '07 #1
Share this Question
Share on Google+
1 Reply


epots9
Expert 100+
P: 1,351
I'm trying to add a button that will update the value of a form field with some text followed by the contents of another field. Here's what I got:

[html]
<form action="<?php echo ($_SERVER['PHP_SELF']); ?>" method="post" name="foo">

{...snip...}

<p>
<b>Item to list on printout:</b>
<input type="text" name="item" size=40 maxlength=80 /></p>
<p><input type="checkbox" name="fl" value="1" CHECKED />
Your order is currently
<input type="text" name="status" size="30" maxlength="60" value="backordered" style="background-color:#ebecfe" />

<input type="button" name="bar" value="Held up waiting on" onClick="document.foo.status.value='held up waiting on' " />

[/html]

I'd like the msg on line 12 to be: 'held up waiting on' . document.foo.item.value
but I don't know how to do that in javascript in a onClick setting.

Thanks in advance,

- Dave (user404)
try this:
Expand|Select|Wrap|Line Numbers
  1. document.foo.status.value='held up waiting on ' + document.foo.item.value;
  2.  
good luck
Jun 18 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.