Flash Games
 FAQ   Search   Memberlist   Usergroups   Register  Profile   Log in to check your private messages   Log in 


Help needed to get data/info from one form to another



 

Post new topic   Reply to topic  
   DEVPPL Forum Index -> JavaScript Forum
View previous topic :: View next topic  
Author Message
DDragon
50+ Club


Joined: 20 Jun 2007
Posts: 64
Location: Australia

PostPosted: Thu Mar 13, 2008 12:48 pm    Post subject: Help needed to get data/info from one form to another Reply with quote

ok here is the problem, i have to forms which have values i wish to be added together i can add together the values in one form all right but im having problems with adding the values of the other form to it... ill post the code for you to look at and try to explaine in detail what im trying to do.

here is the code (HTML and Javascript so you get the whole picture):

Edit: A little re wording.

what i need to do it get the values from form 2 (frmExtras) into the javascript code. so if lets say, chkGen is checked, then the script will then get the value from the hidden text field and add it to the total ammount in form 1 (frmTorder) but i dont know how to go about that any ideas?

Javascript:
Code:

var gen, lights;

var lammount;



function validatetheform()
   {
      if (!document.frmTorder.txtBname.value)
         {
            alert("Please enter your buisness name.");
            document.frmTorder.txtBname.focus();
         }

      else if(!document.frmTorder.txtBaddy.value)
         {
            alert("Please enter you Buisness address.");
            document.frmTorder.txtBaddy.focus();
         }

      else if(!document.frmTorder.txtPcode.value)
         {
            alert("Plese enter your postcode");
            document.frmTorder.txtPcode.focus();
         }

      else if(!document.frmTorder.txtState.value)
         {
            alert("Please enter you state.");
            document.frmTorder.txtState.focus();
         }

      else if(!document.frmTorder.txtSite.value)
         {
            alert("Please enter the event address.");
            document.frmTorder.txtSite.focus();
         }

      return true;
   }


function total_add()
   {

      var bubbleday, simday, slideday, bungiesday;
      var bubble, sim, slide, bungies;
      var bubblet, simt, slidet, bungiest;

      var total;

      // Setting the value for the days
      bubbleday = document.frmTorder.txtBubbledays.value;
      simday = document.frmTorder.txtSimdays.value;
      slideday = document.frmTorder.txtSlidedays.value;
      bungiesday = document.frmTorder.txtBungiedays.value;

      // setting the value for the set price
      bubble = document.frmTorder.txtBubbleprice.value;
      sim = document.frmTorder.txtSimprice.value;
      slide = document.frmTorder.txtSlideprice.value;
      bungies = document.frmTorder.txtBungieprice.value;

      // calculating the total of the individual rides
      bungiest = bungies * bungiesday;
      simt = sim * simday;
      slidet = slide * slideday;
      bubblet = bubble * bubbleday;

      // setting the value total with the ammounts from the rides
      total = bubblet + slidet + simt + bungiest;

      document.frmTorder.txtTotalprice.value = total;

   }



function extras()

   {
      if (document.frmExtras.chkGen = selected)

         {

            gen = document.frmExtras.txtGenprice.value;

         }



      alert("Gen amount is: " + gen);
   
   }


and the html (form 1):

Code:

<form name="frmTorder" method="post" onSubmit="validatetheform()" onReset="document.frmTorder.txtBname.focus()">
            <font color="lightgreen"><strong>*</strong></font>Buisness Name: &nbsp;<input type="text" name="txtBname" size="20"><br />
            <font color="lightgreen"><strong>*</strong></font>Address: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="txtBaddy" size="50"><br />
            <font color="lightgreen"><strong>*</strong></font>Post Code: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="txtPcode" size="4"> <font color="lightgreen"><strong>*</strong></font>State: <input type="text" name="txtState" size="4"><br />

            <br /><hr /><br />

            <font color="lightgreen"><strong>*</strong></font>Address of event: &nbsp;&nbsp;<input type="text" name="txtSite" size="50"><br />
                  
            <font color="lightgreen"><strong>*</strong></font>Start date: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="txtSdate" class="calendarSelectDate" size="10"/> <font color="lightgreen"><strong>*</strong></font>End date of event: <input type="text" name="txtEdate" size="10" class="calendarSelectDate"><br />
            Street Referance: &nbsp;&nbsp;&nbsp;<input type="text" name="txtSref" size="50"><br />

            <br /><hr /><br />

            <center><table name="tblRides" border="0">
               <tr>
                  <td>Rides</td>

                  <td><font color="lightgreen"><strong>*</strong></font>Required Days</td>

                  <td><center>Price</center></td>

               </tr>

               <tr>

                  <td>Trampoline Bungies</td>

                  <td><center><input type="text" name="txtBungiedays" size="2" onchange="total_add()"></center></td>

                  <td class="price"><center><input type="text" name="txtBungieprice" size="7" value="2000.00" disabled></center></td>

               </tr>

               <tr>

                  <td>Tarzan Jumping Castel</td>

                  <td><center><input type="text" name="txtBubbledays" size="2" onChange="total_add()"></center></td>

                  <td class="price"><center><input type="text" name="txtBubbleprice" size="7" value="1200.00" disabled></center></td>

               </tr>

               <tr>

                  <td>Voyager Simulator</td>

                  <td><center><input type="text" name="txtSimdays" size="2" onChange="total_add()"></center></td>

                  <td class="price"><center><input type="text" name="txtSimprice" size="7" value="1850.00" disabled></center></td>

               </tr>

               <tr>

                  <td>Giant Slide</td>

                  <td><center><input type="text" name="txtSlidedays" size="2" onChange="total_add()"></center></td>

                  <td class="price"><center><input type="text" name="txtSlideprice" size="7" value="1850.00" disabled></center></td>

               </tr>

               <tr>

                  <td>Food Van</td>

                  <td><center><input type="text" name="txtFvandays" size="2" onChange="total_add()"></center></td>

                  <td class="price"><center><input type="text" name="txtFvanprice" size="7" value="0.00" disabled></center></td>

               </tr>

               <tr>

                  <td></td>

                  <td>Total Amount Owing: $</td>

                  <td class="price"><input type="text" name="txtTotalprice" size="7" disabled></td>

               </tr>
            </table></center><br />

            <center>Extra Details/Questions: <br /><textarea name="txtComments" rows="8" cols="40">Place any extra details or questions here.</textarea></center><br /><br />

            <center><input type="submit" name="btnSubmit" value="Make Booking"> <input type="reset" name="btnReset" value="Reset the order"></center>
         </form>


(form 2):
Code:

<form name="frmExtras" method="post">
               <li><input type="checkbox" name="chkGen"> Generator (Simulator Only).<input type="hidden" name=txtGenprice" value="1000" onchange="extras()"></li>
               <li><input type="checkbox" name="chkLights"> Lights. <br /><input type="text" name="txtLammount" value="0" size="2" onchange=""> Ammount needed.<input type="hidden" name=txtLprice" value="1000"></li>
            </form>


Now what i need is to be able to get the values of 'frmExtras' into the box 'txtTotalprice' if the check box for chkGen is selected or an ammount from 'txtLammount' if it has a value in it.. ive been trying to nut it out and my own knowledge is just too limited i need help with it... any advice of how to go about it would be great.

DD
Back to top
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    DEVPPL Forum Index -> JavaScript Forum All times are GMT + 1 Hour
Page 1 of 1

 
 
Welcome to DEVPPL.com
You are not logged in, which means that you can't post in the forums.
Click here to Register

If you are a current member here on DEVPPL, please login below:

User: Pass:
Log me on automatically each visit:

 


Powered by phpBB © 2001, 2005 phpBB Group - Modified by DEVPPL

Flash Games - Sitemap