473,406 Members | 2,356 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.

writing from hidden field to text field repost

Hi I'm reposting this question because for some reason can't post
follow up question to this thread.
What I'm trying to do is put the value and text from a a select in to
a text field and to a hidden field respectfully and the value from
dynamically created hidden fiields in to a text fieldin to a text
field all at the same time
Here's the code as viewed through the browser
<body bgcolor="#FFFFFF" text="#000000" >

<SCRIPT LANGUAGE=JavaScript>
<!--
function ch_price (theForm) {
// this changes the price in the price text field
for (i=0; i < 2; i++){
document.form1.oldprice.value = document.form1.prevprice[i].value;//
the hidden fields
document.form1.price.value =
document.form1.size.options[document.form1.size.selectedIndex].value;
document.form1.Tsize.value =
document.form1.size.options[document.form1.size.selectedIndex].text;

}
}
//-->

</SCRIPT>
<form name="form1" method="post" action="" >
<select name="size" id="size" onChange="ch_price(form1)">
<option selected value="189.00">Select
Size/Colour</option>
<option value="179.00" >95x75cm; 37x29"</option>
<option value=" 89.00" >95x75cm; 37x29"</option>
</select>
<br>
<br>

<input type="hidden" name="prevprice" value="99.00">//hidden fields
that holds value for the oldprice txt field
<input type="hidden" name="prevprice" value="189.00">

<input name="oldprice" class="price" type="text" id="oldprice"
readonly = true value="189.00" size="5" >
<input name="price" class="price" type="text" id="price" readonly =
true value="179.00" size="5" >
<input type="hidden" name="Tsize" value="">
</form>

I've tried to simplify it by taking out any code
T.I.A
Jul 23 '05 #1
3 2174
"Roy Adams" <ro*******@ntlworld.com> wrote in message
news:13*************************@posting.google.co m...
Hi I'm reposting this question because for some reason can't post
follow up question to this thread.
What I'm trying to do is put the value and text from a a select in to
a text field and to a hidden field respectfully and the value from
dynamically created hidden fiields in to a text fieldin to a text
field all at the same time


[snip]

Your description and your logic conflict.

Could you rewrite the above using your form field names?


Jul 23 '05 #2
Roy Adams wrote:
Hi I'm reposting this question because for some reason can't post
follow up question to this thread.
What I'm trying to do is put the value and text from a a select in to
a text field and to a hidden field respectfully and the value from
dynamically created hidden fiields in to a text fieldin to a text
field all at the same time
Here's the code as viewed through the browser
<body bgcolor="#FFFFFF" text="#000000" >

<SCRIPT LANGUAGE=JavaScript>
The language attribute is dead and buried, use type:

<script type="text/javascript">
<!--
Hiding scripts hasn't been necessary since Netscape 2, don't bother.
function ch_price (theForm) {
// this changes the price in the price text field
for (i=0; i < 2; i++){
document.form1.oldprice.value = document.form1.prevprice[i].value;//
the hidden fields
It is your job to make sure lines aren't inappropriately wrapped,
always wrap at about 65 characters to allow for a couple of quoted
replys

[...]
<form name="form1" method="post" action="" >
<select name="size" id="size" onChange="ch_price(form1)">
<option selected value="189.00">Select
Size/Colour</option>
Get rid of tabs, use 2 (preferred) or 4 spaces for indenting.

<option value="179.00" >95x75cm; 37x29"</option>
<option value=" 89.00" >95x75cm; 37x29"</option>
Supposed to be selecting siz/color, how does this relate?
<input name="oldprice" class="price" type="text" id="oldprice"
readonly = true value="189.00" size="5" >


Attribute values should be quoted, but readonly doesn't need one. You
may want to put readonly="readonly", but that may fool some browsers
that don't expect it to have a value.

Also, somewhere you used // to comment in HTML - that won't work, you
need to use <!-- -->

[...]

Below is an example of what you are trying to do. Post again if you
need further help.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html><head><title>Copy Text & Values</title>

<script type="text/javascript">

function ch_price (sel,theForm) {

// Get the options array
var opts = sel.options;
// for each option
for (i=0; i < opts.length; i++) {

// if it is selected
if (opts[i].selected && i > 0) {

// copy the value to the value inpput
theForm.elements['valueField'].value = opts[i].value;

// copy the text to the text inpput
theForm.elements['hiddenField'].value = opts[i].text;

} else if (i == 0) {
theForm.elements['valueField'].value = '';
theForm.elements['hiddenField'].value = '';
}
}
}

</script>
</head>
<body>

<form name="form1" id="form1" method="post" action="" ><p>
<select name="size" id="size" onChange="ch_price(this,this.form)">
<option value="" selected>Select Size/Colour</option>
<option value="value1" >Text one</option>
<option value="value2" >Text Two</option>
</select><br><br>

<!-- hidden fields that holds value for the oldprice txt field -->
<input type="text" name="valueField" value="" readonly>
<input type="text" name="hiddenField" value="" readonly>
</p></form>

</body>
</html>

--
Fred
Jul 23 '05 #3
JRS: In article <41c7bee9$0$25868$5a62ac22@per-qv1-newsreader-
01.iinet.net.au>, dated Tue, 21 Dec 2004 16:11:23, seen in
news:comp.lang.javascript, Fred Oz <oz****@iinet.net.auau> posted :
It is your job to make sure lines aren't inappropriately wrapped,
always wrap at about 65 characters to allow for a couple of quoted
replys


Recommendations vary in the range 64-76, but the accepted norm is 72.
That allows sufficient room for reasonable quoting without reaching 80
characters. An unnecessarily small figure, while perfectly OK for
ordinary text, in restrictive for program material. You yourself appear
to be using 72.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME ©
Web <URL:http://www.uwasa.fi/~ts/http/tsfaq.html> -> Timo Salmi: Usenet Q&A.
Web <URL:http://www.merlyn.demon.co.uk/news-use.htm> : about usage of News.
No Encoding. Quotes before replies. Snip well. Write clearly. Don't Mail News.
Jul 23 '05 #4

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

Similar topics

10
by: Randell D. | last post by:
Folks, Perhaps someone can figure this out - this is 'the process of my script' I have a form whereby I can add multiple contacts to a single address. There is only one...
1
by: mark.reichman | last post by:
First off.. Thanks to Grant Wagner for help in a previous thread related to this one. I am at a total loss... I have multiple fields in a form with the same name. Lets call the fields with the...
1
by: Roy Adams | last post by:
Hi Group I'm trying to write from dynamically created hidden fields to a txt field in the onchange event handler within a select. basically the number for the for loop is generated by a field...
4
by: GavMc | last post by:
Hello I am new to internet programming and wonder if anyone can help me with this.... I am trying to pass a hidden field value on a form into another field on the form so that it can then be...
4
by: Magnus Blomberg | last post by:
Hello! I have a problem when using a hidden field to send a value to the server. Below you can see my code in simplyfied versions. What I'm trying to do is: 1. The user browses for a picture...
2
by: Bill Steele | last post by:
I want to have a window pop up with a form. When the form is submitted, it needs to pass along the URL of the original window. If find on th web eight gazillion descriptions of how to pass data...
8
by: =?Utf-8?B?cGVsZWdrMQ==?= | last post by:
i have a GridView and a hidden field : <asp:TemplateField Visible=false > <ItemTemplate > <asp:HiddenField Value="<%#Eval("isActive")%>" id="hidIsActive" runat=server /> </ItemTemplate>...
1
by: mark | last post by:
Forgive me if this seems like a stupid question but I need help... I'm trying to do a simple online form that emails me the results from a few fields. Here is the code: <form...
11
by: newbie | last post by:
i have a form in which a hidden field (initial value as '0', and my javascript set it to '1' when an event is trigged). In the same form, i have a reset field. But I realized that the hidden field...
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?
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
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,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.