Jump to content

Copy a field value


Beano

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
Link to comment
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
Link to comment
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.
Link to comment
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]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.