Beano Posted April 17, 2006 Share Posted April 17, 2006 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 field1How 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 Quote Link to comment https://forums.phpfreaks.com/topic/7635-copy-a-field-value/ Share on other sites More sharing options...
GingerRobot Posted April 17, 2006 Share Posted April 17, 2006 You will need to use javascript for this, not php. Quote Link to comment https://forums.phpfreaks.com/topic/7635-copy-a-field-value/#findComment-27837 Share on other sites More sharing options...
Beano Posted April 17, 2006 Author Share Posted April 17, 2006 Any clues on the javascript to use? Quote Link to comment https://forums.phpfreaks.com/topic/7635-copy-a-field-value/#findComment-27838 Share on other sites More sharing options...
GingerRobot Posted April 17, 2006 Share Posted April 17, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/7635-copy-a-field-value/#findComment-27841 Share on other sites More sharing options...
Beano Posted April 17, 2006 Author Share Posted April 17, 2006 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 PHPBefore 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. Quote Link to comment https://forums.phpfreaks.com/topic/7635-copy-a-field-value/#findComment-27852 Share on other sites More sharing options...
legohead6 Posted April 17, 2006 Share Posted April 17, 2006 [!--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] Quote Link to comment https://forums.phpfreaks.com/topic/7635-copy-a-field-value/#findComment-27894 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.