Jump to content

Auto populate text field from a text field from another form


songweaver

Recommended Posts

Hey guys,

 

I am a webmaster for my church and I am fairly new to PHP. What am trying to is when a visitor goes to our radio ministry page and clicks a button which the message number is displayed in the read only textbox, it will go to my request CD page and auto populate the message number in that text field form the readonly text field from the previous page. I will show my code for both pages for you to review.

 

 

This is the Radio page (where I want to take the message number value from)

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="Living Word Community Church radio ministry" />
    <meta name="keywords" content="reformed radio fort worth, reformed radio dallas, biblical radio fort worth, biblical radio dfw"  />
    <title>In Light of Scripture-Radio Ministry</title>
    <link href="_css/Main.css" rel="stylesheet" type="text/css" />
    <script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script>

    <link href="SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" />
    </head>

    <body>

    <div class="container">
    <div class="header"><a href="index.php"><img src="_images/LWCCWeb.jpg" alt="Insert Logo Here" name="Insert_logo" width="960" height="200" id="Insert_logo" style="background: #D8BF78; display:block;" /></a>
       <?php include("_includes/header.php"); ?>
    <div class="sidebar1">
        <p></p>
         <table width="150" border="0" cellpadding="10" align="left">
      <tr>
        <td><a href="directions.php"><img src="_images/ChurchBox.png" width="150" height="125" alt="Directions" /></a></td>
      </tr>
      <tr>
        <td><img src="_images/Service Times.png" width="150" height="778" alt="Service Times" /></td>
      </tr>
    </table>

        <!-- end .sidebar1 --></div>
     
    <div class="content">
       <div id="radio"></div>
        <table width="600" border="0" cellpadding="10">
      <tr>
        <td><img src="_images/ILOS.png" width="600" height="111" alt="In Light of Scripture" /></td>
        </tr>
         <tr>
             <td style=" padding-top:25px"><p><font size="5"><b>In Light of Scripture</b> has been locally broadcast for more
             than 25 years.<br />
              This Sunday morning radio program features the expositional teaching of Pastor Stan McGehee Jr.
             </font><p/></td>
          </tr>
       
        </table>
       
        <div id="mediagraph"><a href="http://kdkr.org" target="_blank"><img src="_images/kdkr.jpg" width="300" height="200" alt="Braodcast on KDKR 91.3 Sunday    
           Mornings at 7:30" /></a></div>
           
            <br  /><br  />
            <font size="2"><p align="center"><b>The sermon featured this week on "In Light of Scipture" is</b></p></font>
            <font size="2"><p align="center" style="color:#711726"><b><i>Peace Despite Tribulation</i></b></p></font>
            <div id="messagenumber" align="center">
            <form action="" method="get" name="messagenumber">
            <input name="" type="text" value="JR-843" size="6" readonly="readonly" />
            <input name="GetMessage" type="button" value="Get Message" />
            </form>
            </div>
        <!-- end .content --></div></div>
      <div class="sidebar2">
        <table width="150" border="0" cellpadding="16" align="left">
          <tr>
            <td><a href="reformation.php"><img src="_images/MenuBox1.png" width="150" height="125" alt="What Do We Mean by Reformed?" /></a></td>
          </tr>
          <tr>
            <td><a href="ServiceTimesAndCal.php"><img src="_images/MenuBox2.png" width="150" height="125" alt="Worship Service Schedule and Calendar" /></a></td>
          </tr>
          <tr>
            <td><a href="radio.php"><img src="_images/MenuBox3.png" width="150" height="125" alt="In Light of Scripture Radio Ministry" /></a></td>
          </tr>
          <tr>
            <td><a href="cable.php"><img src="_images/MenuBox4.png" width="150" height="125" alt="Living Word Today Cable Program" /></a></td>
          </tr>
          <tr>
            <td><a href="Sermons.php"><img src="_images/MenuBox5.png" width="150" height="125" alt="Listen to Sermons Online" /></a></td>
          </tr>
           <tr>
              <td><a href="http://www.lwcchurch.org/blog/" target="_blank"><img src="_images/MenuBox6.png" width=
               "150" height="125" alt="Read our reformed blog" /></a></td>
          </tr>
        </table>
       
        <!-- end .sidebar2 --></div>
        <?php include("_includes/footer.php"); ?>
      <!-- end .container --></div>
      <script type="text/javascript">
    var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgDown:"SpryAssets/SpryMenuBarDownHover.gif", imgRight:"SpryAssets/SpryMenuBarRightHover.gif"});
    var MenuBar2 = new Spry.Widget.MenuBar("MenuBar2", {imgDown:"SpryAssets/SpryMenuBarDownHover.gif", imgRight:"SpryAssets/SpryMenuBarRightHover.gif"});
    </script>
    </body>
    </html>

 

 

This is for the CD request form. I want it to populate the Message# text field

 

   

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="Order Living Word Community Church sermons and teachings on CD" />
    <meta name="keywords" content="Stan McGehee cd, Reformed teachings on cd, Biblical teachings on cd, LWCC cds"  />
    <title>Order CD's Online</title>
    <link href="_css/Main.css" rel="stylesheet" type="text/css" />
    <link href="js/jquery.datepick.css" rel="stylesheet" type="text/css" />
    <script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script>
    <script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
    <link href="SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="jquery/jquery-1.5.js"></script>
    <script type="text/javascript" src="js/jquery.datepick.js"></script>
    <script src="SpryAssets/SpryValidationSelect.js" type="text/javascript"></script>
    <script src="SpryAssets/SpryValidationRadio.js" type="text/javascript"></script>
    <link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
       $(function() {
       $('#popupDatepicker').datepick();
       $('#inlineDatepicker').datepick({onSelect: showDate});
    });

    function showDate(date) {
       
    }

       </script>



    <link href="SpryAssets/SpryValidationSelect.css" rel="stylesheet" type="text/css" />
    <link href="SpryAssets/SpryValidationRadio.css" rel="stylesheet" type="text/css" />
    </head>

    <body>

    <div class="container">
    <div class="header"><a href="index.php"><img src="_images/LWCCWeb2.png" alt="Insert Logo Here" name="Insert_logo" width="960" height="200" id="Insert_logo" style="background: #D8BF78; display:block;" /></a>
       <?php include("_includes/header.php"); ?>
       
    <div class="sidebar1">
        <p></p>
         <table width="150" border="0" cellpadding="10" align="left">
      <tr>
        <td><a href="directions.php"><img src="_images/ChurchBox.png" width="150" height="125" alt="Directions" /></a></td>
      </tr>
      <tr>
        <td><img src="_images/Service Times.png" width="150" height="890" alt="Service Times" /></td>
      </tr>
    </table>

        <!-- end .sidebar1 --></div>
     
    <div class="content">
        
       <h2 style="padding-left:50px"> Order messages on CD from LWCC</h2>
       <div id"form">
       
        <form action="FormToEmail2.php" method="post">

       


        <table width="550" border="0" cellpadding="10">
         <tr>
           <td><table width="550" border="0" cellpadding="10">
      <tr>
        <td width="190">First Name:</td>
        <td width="314"><span id="spryfirstname">
        <input name="firstname" type="text" id="firstname" maxlength="20" />
        <span class="textfieldMaxCharsMsg">Too many letters</span><span class="textfieldRequiredMsg">Enter first name </span></span></td>
      </tr>
      <tr>
        <td>Last Name:</td>
        <td><span id="sprylastname">
        <input name="lastname" type="text" id="lastname" maxlength="20" />
        <span class="textfieldRequiredMsg">Enter last name</span><span class="textfieldMaxCharsMsg">Too many letters</span></span></td>
      </tr>
      <tr>
       <td>Email<font size="2"> (So we can confirm if needed)</font>:</td>
        <td><span id="spryemail">
        <input name="email" type="text" id="email" maxlength="50" />
        <span class="textfieldRequiredMsg">Enter Email</span><span class="textfieldInvalidFormatMsg">Must be Email.</span><span class="textfieldMaxCharsMsg">Email too long</span></span></td>
      </tr>
      <tr>
       <td>Street:</td>
        <td><span id="sprystreet"><span id="sprystreet">
        <input name="street" type="text" id="street" maxlength="50" />
        <span class="textfieldRequiredMsg">Enter Street Address</span><span class="textfieldMaxCharsMsg">Exceeded maximum number of characters.</span></span></td>
      </tr>
      <tr>
       <td>City:</td>
        <td><span id="sprycity"><span id="sprytextfield5">
        <input name="City" type="text" id="city" maxlength="50" />
        <span class="textfieldRequiredMsg">Enter your city</span><span class="textfieldMaxCharsMsg">Exceeded maximum number of characters.</span></span><span class="textfieldRequiredMsg">Enter Email</span><span class="textfieldInvalidFormatMsg">Must be Email.</span><span class="textfieldMaxCharsMsg">Email too lon</span></span></td>
      </tr>
       <tr>
       <td>Apartment number:</td>
        <td><span id="aptnum">
        <input name="Apt number" type="text" id="aptnum" maxlength="6" width="80px" />
        <span class="textfieldRequiredMsg">Enter Email</span><span class="textfieldInvalidFormatMsg">Must be Email.</span><span class="textfieldMaxCharsMsg">Email too long</span></span></td>
      </tr>
      <tr>
       <td>State:</td>
        <td><span id="spryselect1">
          <select name="statelist">
            <option value="null"></option>
            <option value="Alabama">AL</option>
            <option value="Alaska">AK</option>
            <option value="Arkansas">AR</option>
            <option value="Arizona">AZ</option>
            <option value="California">CA</option>
            <option value="Colorado">CO</option>
            <option value="Connecticut">CT</option>
            <option value="Deleware">DE</option>
            <option value="District of Columbia">DC</option>
            <option value="Florida">FL</option>
            <option value="Georgia">GA</option>
            <option value="Hawaii">HI</option>
            <option value="Idaho">ID</option>
            <option value="Iowa">IA</option>
            <option value="Illinois">IL</option>
            <option value="Indiana">IN</option>
            <option value="Kansas">KS</option>
            <option value="Kentucky">KY</option>
            <option value="Louisiana">LA</option>
            <option value="Massachusetts">MA</option>
            <option value="Maryland">MD</option>
            <option value="Maine">ME</option>
            <option value="Michigan">MI</option>
            <option value="Minnesota">MN</option>
            <option value="Missouri">MO</option>
            <option value="Mississippi">MS</option>
            <option value="Montana">MT</option>
            <option value="Nebraska">NE</option>
            <option value="New Hampshire">NH</option>
            <option value="New Jersey">NJ</option>
            <option value="New Mexico">NM</option>
            <option value="Nevada">NV</option>
            <option value="New York">NY</option>
            <option value="North Carolina">NC</option>
            <option value="North Dakota">ND</option>
            <option value="Ohio">OH</option>
            <option value="Oklahoma">OK</option>
            <option value="Oregon">OR</option>
            <option value="Pennslyvania">PA</option>
            <option value="Rhode Island">RI</option>
            <option value="South Carolina">SC</option>
            <option value="Tennessee">TN</option>
            <option value="Texas">TX</option>
            <option value="Utah">UT</option>
            <option value="Vermont">VT</option>
            <option value="Virginia">VA</option>
            <option value="Washington">WA</option>
            <option value="Wisconsin">WI</option>
            <option value="West Virginia">WV</option>
            <option value="Wyoming">WY</option>
          </select>
          <span class="selectRequiredMsg">Please select state</span></span></td>
      </tr>
      <tr>
       <td>Zip Code:</td>
        <td><span id="spryzip"><span id="sprytextfield6">
        <input name="Zip Code" type="text" id="zip" maxlength="50" />
        <span class="textfieldRequiredMsg">Enter Zip Code</span><span class="textfieldInvalidFormatMsg">Zip Code is 5 numbers.</span></span><span class="textfieldRequiredMsg">Enter Email</span><span class="textfieldInvalidFormatMsg">Must be Email.</span><span class="textfieldMaxCharsMsg">Email too lo</span></span></td>
      </tr>
      <tr>
        <td>Which Pastor or Teacher?</td>
        <td>
          <div id="spryradio1">
            <table width="250">
              <tr>
                <td><label>
                  <input type="radio" name="Speaker" value="Pastor Stan McGehee" id="radiogroup_4" />
                  Pastor Stan McGehee Sr</label></td>
              </tr>
              <tr>
                <td><label>
                  <input type="radio" name="Speaker" value="Pastor Stan McGehee Jr" id="radiogroup_5" />
                  Pastor Stan McGehee Jr</label></td>
              </tr>
              <tr>
                <td><label>
                  <input type="radio" name="Speaker" value="Pastor Jack McFarland" id="radiogroup_6" />
                  Pastor Jack McFarland</label></td>
              </tr>
              <tr>
                <td><label>
                  <input type="radio" name="Speaker" value="Steve Bader" id="radiogroup_7" />
                  Steve Bader</label></td>
              </tr>
            </table>
            <span class="radioRequiredMsg">Please select speaker</span></div></td>
      </tr>
      <tr>
      <td>Where did you hear message?</td>
      <td>
         <div id="spryradio2">
           <table width="200">
             <tr>
               <td><label>
                 <input type="radio" name="How did you hear?" value="At LWCC" id="RadioGroup1_0" />
                 At our church</label></td>
             </tr>
             <tr>
               <td><label>
                 <input type="radio" name="How did you hear?" value="On the Radio" id="RadioGroup1_1" />
                 On the Radio</label></td>
             </tr>
             <tr>
               <td><label>
                 <input type="radio" name="How did you hear?" value="On Cable" id="RadioGroup1_2" />
                 On Cable</label></td>
             </tr>
           </table>
           <span class="radioRequiredMsg">Please make a selection</span></div></td>
      </tr>
      <tr>
       <td>What service?</td>
        <td><div id="spryradio3">
          <table width="248">
            <tr>
              <td width="240"><label>
                <input type="radio" name="When did you hear message?" value="Sunday AM" id="When did you hear message?_0" />
                Sunday AM</label></td>
            </tr>
            <tr>
              <td><label>
                <input type="radio" name="When did you hear message?" value="Sunday PM" id="When did you hear message?_1" />
                Sunday PM</label></td>
            </tr>
            <tr>
              <td><label>
                <input type="radio" name="When did you hear message?" value="Wednesday PM" id="When did you hear message?_2" />
                Wednesday PM</label></td>
            </tr>
            <tr>
              <td><label>
                <input type="radio" name="When did you hear message?" value="Adult Sunday School" id="When did you hear message?_3" />
                Adult Sunday School</label></td>
            </tr>
          </table>
          <span class="radioRequiredMsg">Please make a selection.</span></div></td>
        </tr>
      <tr>
        <td>Message Number <font size="2">(If known)</font>: </td>
        <td><input name="Message#" type="text" id="messagenumber" maxlength="50" /></td>
      </tr>
            </table>

    </td>
           </tr>
         <tr>
           <td><table width="550" border="0" cellpadding="10">
               <h3 style="padding-left:135px">Please pick date of message</h3>
                <div id="selectdate" align="center"><input id="inlineDatepicker" name="When Did You Hear?" type="text" /></div>
             
               

                <script type="text/javascript">

             var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
    document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
    </script>
    <script type="text/javascript">
    var pageTracker = _gat._getTracker("UA-4715900-1");
    pageTracker._initData();
    pageTracker._trackPageview();

    </script></table></td>

     
      <tr>
        <td style="padding-left:250px"><input name="submit" value="Submit" type="submit" />  <input name="clearBtn" type="reset" /></td>
       
      </tr>
    </table>
    </td>
           </tr>
         </table>
       

        </form></div>
      <!-- end .content --></div></div>
      <div class="sidebar2">
        <table width="150" border="0" cellpadding="25" align="left">
          <tr>
            <td><a href="reformation.php"><img src="_images/MenuBox1.png" width="150" height="125" alt="What Do We Mean by Reformed?" /></a></td>
          </tr>
          <tr>
            <td><a href="ServiceTimesAndCal.php"><img src="_images/MenuBox2.png" width="150" height="125" alt="Worship Service Schedule and Calendar" /></a></td>
          </tr>
          <tr>
            <td><a href="radio.php"><img src="_images/MenuBox3.png" width="150" height="125" alt="In Light of Scripture Radio Ministry" /></a></td>
          </tr>
          <tr>
            <td><a href="cable.php"><img src="_images/MenuBox4.png" width="150" height="125" alt="Living Word Today Cable Program" /></a></td>
          </tr>
          <tr>
            <td><a href="Sermons.php"><img src="_images/MenuBox5.png" width="150" height="125" alt="Listen to Sermons Online" /></a></td>
          </tr>
           <tr>
              <td><a href="http://lwcchurch.blogspot.com" target="_blank"><img src="_images/MenuBox6.png" width="150" height="125" alt="Read our reformed blog" /></a></td>
          </tr>
        </table>
       
        <!-- end .sidebar2 --></div>
       <?php include("_includes/footer.php"); ?>
      <!-- end .container --></div>
    <script type="text/javascript">
    var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgDown:"SpryAssets/SpryMenuBarDownHover.gif", imgRight:"SpryAssets/SpryMenuBarRightHover.gif"});
    var MenuBar2 = new Spry.Widget.MenuBar("MenuBar2", {imgDown:"SpryAssets/SpryMenuBarDownHover.gif", imgRight:"SpryAssets/SpryMenuBarRightHover.gif"});
    var sprytextfield1 = new Spry.Widget.ValidationTextField("spryfirstname", "none", {validateOn:["blur"], maxChars:20});
    var sprytextfield2 = new Spry.Widget.ValidationTextField("sprylastname", "none", {maxChars:20, validateOn:["blur"]});
    var sprytextfield3 = new Spry.Widget.ValidationTextField("spryemail", "email", {maxChars:50, validateOn:["blur"]});
    var sprytextfield4 = new Spry.Widget.ValidationTextField("sprystreet", "none", {validateOn:["blur"], maxChars:50});
    var sprytextfield5 = new Spry.Widget.ValidationTextField("sprytextfield5", "none", {maxChars:50, validateOn:["blur"]});
    var spryselect1 = new Spry.Widget.ValidationSelect("spryselect1", {validateOn:["blur"]});
    var sprytextfield6 = new Spry.Widget.ValidationTextField("sprytextfield6", "zip_code", {validateOn:["blur"]});
    var spryradio1 = new Spry.Widget.ValidationRadio("spryradio1");
    var spryradio2 = new Spry.Widget.ValidationRadio("spryradio2");
    var sprytextfield7 = new Spry.Widget.ValidationTextField("sprymessagenumber", "none", {isRequired:false});
    var spryradio3 = new Spry.Widget.ValidationRadio("spryradio3");
    </script>
    </body>
    </html>

Link to comment
Share on other sites

Here's a basic example of what I think you are trying to acheive:

 

The item being clicked(read only text):

<form action="link to next page" method="post">
<input type="text" readonly value="yourVal" name="populateInfo">
<input type="submit" value="click here to go to next page and populate value">
</form>

 

Now, the next page where the click takes you:

all you have to do is echo out the posted var into your form field...

<input type="text" name="populatedField" value="<?php echo $_POST['populateInfo']; ?>">

 

Then you're done! PHP will place any form inputs into one of two arrays based on the method you select: post - is a hidden array that can only be affecting through your scripting. There's also get, which shows all the passed data in your url, like this: mypage.html?field1=value&field2=value, you've probably seen some url's like that before.

 

Hope this helped.

 

E

Link to comment
Share on other sites

Put the message into a variable, drop it in a session or pass it with get/post, put that variable in between the starting and ending tags of the <textarea> or in the value= portion of an input text box - voila.  Let me know if you don't know how to do this, we'll get it figured out.  I didn't just do it for you because that was a lot of code to look through, it might help if you shorten then down to the exact part where the message is contained and then the exact part where you want it to show up and I'll show you how to do it.

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.