473,406 Members | 2,217 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

objects/forms

How can I code a button to change the values in multiple text fields? Do I
use an && or something similar? It would be very nice to see an example,
because I cannot find this in the tutorials that I have been reading.

--

Jul 23 '05 #1
10 1045
sayimsick wrote:
How can I code a button to change the values in multiple text fields? Do I
use an && or something similar? It would be very nice to see an example,
because I cannot find this in the tutorials that I have been reading.

.... onclick="a.value='A';b.value='B';c.value='C'; ....">

Assuming textfields are in same form as the button, and that the
textfields are named "a", "b" and "c".

Mick
Jul 23 '05 #2
In article <V-********************@comcast.com>, sa*******@comcast.net
enlightened us with...
How can I code a button to change the values in multiple text fields? Do I
use an && or something similar? It would be very nice to see an example,
because I cannot find this in the tutorials that I have been reading.


What do you mean?
Can you clarify the question?

--
--
~kaeli~
Shotgun wedding: A case of wife or death.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #3
Thanks, I'll try this later!

"Mick White" <mw******@BOGUSrochester.rr.com> wrote in message
news:jL*******************@twister.nyroc.rr.com...
sayimsick wrote:
How can I code a button to change the values in multiple text fields? Do I use an && or something similar? It would be very nice to see an example, because I cannot find this in the tutorials that I have been reading.

... onclick="a.value='A';b.value='B';c.value='C'; ....">

Assuming textfields are in same form as the button, and that the
textfields are named "a", "b" and "c".

Mick

Jul 23 '05 #4
Okay, I have the javascript in the same form as my text fields, and the
fields are correctly named. When I push the button on the web page, nothing
happens. Can you help me further? Thank you very much. (I'm using a PHP
loop to generate the part after onClick, and that is why I have some empty
values)
Each of the fields that will be manipulated is a text (<input type='text'
....)
<script language="JavaScript"><!--

if (window.print)

document.write("<input type='button' value='This week is next week'
onClick=sun10.value='';sun11.value='hi';sun12.valu e='hi';sun13.value='';>");

//--></script>
"Mick White" <mw******@BOGUSrochester.rr.com> wrote in message
news:jL*******************@twister.nyroc.rr.com...
sayimsick wrote:
How can I code a button to change the values in multiple text fields? Do I use an && or something similar? It would be very nice to see an example, because I cannot find this in the tutorials that I have been reading.

... onclick="a.value='A';b.value='B';c.value='C'; ....">

Assuming textfields are in same form as the button, and that the
textfields are named "a", "b" and "c".

Mick

Jul 23 '05 #5
sayimsick wrote:

Each of the fields that will be manipulated is a text (<input type='text'
...)
See example:

http://www.mickweb.com/demo/dynamicButton.html

<form>
<input name="sun13" type="text" value="stuff">
<input name="sun11" type="text" value="stuff">
<input name="sun12" type="text" value="stuff">
<input name="sun10" type="text" value="stuff">
<script type="text/JavaScript">
document.write("<input type='button' value='This week is next week'
onclick=\"sun10.value='';sun11.value='hi';sun12.va lue='hi';sun13.value='';\"") </script>
</form>

Mick

"Mick White" <mw******@BOGUSrochester.rr.com> wrote in message
news:jL*******************@twister.nyroc.rr.com...

Jul 23 '05 #6
Mick White <mw******@BOGUSrochester.rr.com> writes:
<form>
(The action attribute is required in HTML 4)
<input name="sun13" type="text" value="stuff"> .... <script type="text/JavaScript">
document.write("<input type='button' value='This week is next week'
onclick=\"sun10.value='';sun11.value='hi';sun12.va lue='hi';sun13.value='';\"


There are browsers where this will fail because the properties of the
containing form element is not added to the scope chain of the onclick
handler. A safer method is:
onclick=\"var f=this.form.elements;f.sun10.value='',f.sun11.valu e='hi' ...

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #7
Lasse Reichstein Nielsen wrote:
Mick White <mw******@BOGUSrochester.rr.com> writes:
<script type="text/JavaScript">
document.write("<input type='button' value='This week is next week'
onclick=\"sun10.value='';sun11.value='hi';sun12.va lue='hi';sun13.value='';\"

There are browsers where this will fail because the properties of the
containing form element is not added to the scope chain of the onclick
handler. A safer method is:
onclick=\"var f=this.form.elements;f.sun10.value='',f.sun11.valu e='hi' ...


Yes, you're probably right. But I haven't found a browser that chokes on it.
Mick
/L

Jul 23 '05 #8
hmmmm something is still wrong, even if I use your exact script, and I know
that the script should work because it works on that page.
Does it matter that some fields do not exist that the button refers to?
Does it matter that the name is in single quotes? Does it matter that it is
separated by a few rows and the submit button? Did I put a semicolon in the
wrong spot? Thank you very much for helping me, even though I'm sure that
I'm a frustrating beginner to you.

//////////////////////////////////////////////////////
This is what I have in php, and then I will show you how it gets translated:

echo"<TD><input name='$sun_one' type='text' value='$sun1[$i]'></TD>";

/*some table rows are here]*/

<TR>
<TD>
echo"javabutton is $javabutton<br>
<script language=\"JavaScript\"><!--
document.write(\"<input type='button' value='This week is next week'
onclick=\\\"$javabutton\\\">\")
//--></script>
</TD>
</TR>
</TABLE>";

Here is the translated web page exerpt:

<TD><input name='sun12' type='text' value='34'></TD>
<script language="JavaScript"><!--

javabutton is
sun10.value='';sun11.value='hi';sun12.value='hi';s un13.value='';<br>

document.write("<input type='button' value='This week is next week'
onclick=\"sun10.value='';sun11.value='hi';sun12.va lue='hi';sun13.value='';\"
")
//--></script>
"Mick White" <mw******@BOGUSrochester.rr.com> wrote in message
news:m2*********************@twister.nyroc.rr.com. .. sayimsick wrote:

Each of the fields that will be manipulated is a text (<input type='text' ...)


See example:

http://www.mickweb.com/demo/dynamicButton.html

<form>
<input name="sun13" type="text" value="stuff">
<input name="sun11" type="text" value="stuff">
<input name="sun12" type="text" value="stuff">
<input name="sun10" type="text" value="stuff">
<script type="text/JavaScript">
document.write("<input type='button' value='This week is next week'

onclick=\"sun10.value='';sun11.value='hi';sun12.va lue='hi';sun13.value='';\"
>")

</script>
</form>

Mick

"Mick White" <mw******@BOGUSrochester.rr.com> wrote in message
news:jL*******************@twister.nyroc.rr.com...

Jul 23 '05 #9
sayimsick wrote:
hmmmm something is still wrong, even if I use your exact script, and I know
that the script should work because it works on that page.
Does it matter that some fields do not exist that the button refers to?
Absolutely. You can test for this in PHP, or in js.
- if(sun10 && sun11 && ...)
Does it matter that the name is in single quotes?
NO

Does it matter that it is separated by a few rows and the submit button?
No, as long as the textboxes and form controls are within the same form.
And within <form> </form> pair.

Did I put a semicolon in the wrong spot?

Looks OK
Mick

Jul 23 '05 #10
Thank you VERY much. The button works perfectly now.

"Mick White" <mw******@BOGUSrochester.rr.com> wrote in message
news:jI********************@twister.nyroc.rr.com.. .
sayimsick wrote:
hmmmm something is still wrong, even if I use your exact script, and I know that the script should work because it works on that page.
Does it matter that some fields do not exist that the button refers to?


Absolutely. You can test for this in PHP, or in js.
- if(sun10 && sun11 && ...)
Does it matter that the name is in single quotes?


NO

Does it matter that it is
separated by a few rows and the submit button?


No, as long as the textboxes and form controls are within the same form.
And within <form> </form> pair.

Did I put a semicolon in the
wrong spot?

Looks OK
Mick

Jul 23 '05 #11

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

Similar topics

1
by: Andrés Giraldo | last post by:
Hi! I'm trying to pass trough all the objects of a form but I have some text inputs in a DIV and I have many DIVs like this on my form. I'm doing something like: for (i = 0; i <...
2
by: Jonathan LaRosa | last post by:
Hi all - I'm wondering if anyone has (or knows of) a tool that will allow me to search through VB code, tables, queries, reports, forms, and other objects, for references to all other types of...
3
by: SV | last post by:
Dear all, In my application I have a lot of hidden fields. I want to make them invisible for the users though for debugging reasons I want to make them visible. So I want to add these objects to...
15
by: Wiktor Zychla | last post by:
today we've found a critical issue regarding the ListView from Windows.Forms. it was confirmed on several machines with Win2K and XP. here's the problem: create a ListView with about 50000 rows....
2
by: Evan | last post by:
Hi, What is the best method to share objects (such as a SqlConnection) across many forms. I am currently passing the SqlConnection in to other forms from the main form through the other forms'...
2
by: headware | last post by:
I am new to 3-tiered design and am in the process of designing an application that will work with ASP.NET as well as Windows Forms (and possibly with a PDA of some sort down the road). My question...
3
by: Retep | last post by:
Hi all, hopefully someone can answer the following mystery for me: I have the following (simplified) application setup: Main Form | Form |
1
by: Mike | last post by:
Hi All, Is there a good book or paper on conceptualizing Winforms as objects? In object-oriented programming I don't find it diffiucult to see "student", "person", or "car" as objects, but I do...
5
meLady
by: meLady | last post by:
Hello, I have two database applications and they are: - the (A) application is for administration use. - the (B) application is for normal users use. the idea is that: I made the (A)...
16
by: Wayne | last post by:
I've read that one method of repairing a misbehaving database is to save all database objects as text and then rebuild them from the text files. I've used the following code posted by Lyle...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...

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.