Jump to content


Photo

Copy a field value


  • Please log in to reply
5 replies to this topic

#1 Beano

Beano
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 17 April 2006 - 08:26 PM

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

#2 GingerRobot

GingerRobot
  • Staff Alumni
  • Advanced Member
  • 4,086 posts
  • LocationUK

Posted 17 April 2006 - 08:44 PM

You will need to use javascript for this, not php.

#3 Beano

Beano
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 17 April 2006 - 08:46 PM

Any clues on the javascript to use?

#4 GingerRobot

GingerRobot
  • Staff Alumni
  • Advanced Member
  • 4,086 posts
  • LocationUK

Posted 17 April 2006 - 08:56 PM

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

#5 Beano

Beano
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 17 April 2006 - 09:23 PM

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.

#6 legohead6

legohead6
  • Members
  • PipPipPip
  • Advanced Member
  • 434 posts

Posted 17 April 2006 - 11:02 PM

[!--quoteo(post=365674:date=Apr 17 2006, 03:44 PM:name=GingerRobot)--][div class=\'quotetop\']QUOTE(GingerRobot @ Apr 17 2006, 03:44 PM) View Post[/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]

<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>

"Syntax error" .. WHERE THE **** IS IT?!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users