Jump to content

Archived

This topic is now archived and is closed to further replies.

Beano

Copy a field value

Recommended Posts

I'm sure there is an easy solution to my problem.

I have a simple form.

In it I have a drop down menu, user to select a text value. This to go to field1

How do I copy the text value entered into field1 into field2?

I am a complete novice. If you can help please give me lots of detail.
Beano

Share this post


Link to post
Share on other sites
Ok, if i understand your correctly, you have a drop down box with a list of things in it. When one of these is selected you want that value to go into a text box?

<script type="text/javascript" language="JavaScript"><!--
function change()
{
document.form.textfield.value = document.form.select.value
}
// --></script>


<FORM ACTION="actionofyourfrom" METHOD="POST" NAME="form">
<SELECT NAME="select" ONCHANGE="change()">
//All your values in your drop down box
</SELECT>
<INPUT TYPE="TEXT" NAME="textfield">

Edit: please note, im no javascript expert. Its largely a mystery to me

Share this post


Link to post
Share on other sites
To be clear on what Im trying to do.

The user will select a value from a drop down list. That text value goes into field1. I can do this in PHP

Before the form is entered I want to copy the field1 value to field2.

That way I end up with the same value in two fields in my form query.

Share this post


Link to post
Share on other sites
[!--quoteo(post=365674:date=Apr 17 2006, 03:44 PM:name=GingerRobot)--][div class=\'quotetop\']QUOTE(GingerRobot @ Apr 17 2006, 03:44 PM) [snapback]365674[/snapback][/div][div class=\'quotemain\'][!--quotec--]
You will need to use javascript for this, not php.
[/quote]

ya php works..... look here...
heres one in action! [a href=\"http://www.mattswebpage.com/test/testvalue.php\" target=\"_blank\"]http://www.mattswebpage.com/test/testvalue.php[/a]

[code]<html>
<body>

<form name="form" method="get" name="form">
  <p><select size="1" name="test1">
  <option>11</option>
  <option>22</option>
  <option>33</option>
  <option>44</option>
  </select></p>
  <p><input type="submit" value="Submit" name="submit"></p>
</form>

<?php

$tt=$_GET['test1'];
$t2=$_GET['show'];

if(isset($_GET['submit'])){

echo "<input type=text name=show size=20 value=$tt readonly>";

}
?>
</html>[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.