Results 1 to 2 of 2

Thread: Passing data from one form to another.

  1. #1
    Regular Member Travlin_Man's Avatar
    Join Date
    Mar 2002
    Location
    Michigan, USA
    Posts
    384

    Passing data from one form to another.

    Help!!! I am lost... I am trying to get data from several selectable fields in one form to pass to a textarea on the output page.

    I am only getting the option value to pass and then only the last option value of the form.

    I would like it to identify the option value by name and I am hoping to get all of the selctions to appear in the textarea of the output page...

    Below are examples...any help would be appreciated

    here is a portion of my input form:

    <form name="form1" action="output.html">
    <table width="100%" border="0" cellspacing="5" cellpadding="0">
    <tr>
    <td><div align="right">SELECT A PROCESSOR/BOARD COMBO:</div></td>
    <td><select name="PROCESSOR" id="select">
    <option value="0" selected>NONE
    <option value="120.00">AMD SEMPRON 2400+
    <option value="145.00">AMD SEMPRON 2600+
    <option value="150.00">AMD AHTLON XP 3000+
    <option value="210.00">INTEL PENTIUM 4 2.4 GHZ
    <option value="250.00">INTEL PENTIUM 4 2.8 GHZ
    <option value="375.00">AMD ATHLON 64 3000+ </select></td>
    </tr>
    <tr>
    <td><div align="right">SELECT MEMORY:</div></td>
    <td><select name="MEMORY" id="select2">
    <option value="0" selected>NONE</option>
    <option value="60.00">128 MB DDR RAM</option>
    <option value="90.00">256 MB DDR RAM</option>
    <option value="130.00">512 MB DDR RAM</option>
    <option value="160.00">1 GB DDR RAM</option>
    </select></td>
    </tr>
    <tr>
    <td><div align="right">SELECT A HARD DRIVE:</div></td>
    <td> <select name="HARDDRIVE" id="select3">
    <option value="0" selected>NONE</option>
    <option value="40.00">20 GB IDE DRIVE</option>
    <option value="70.00">40 GB IDE DRIVE</option>
    <option value="110.00">80 GB IDE DRIVE</option>
    <option value="160.00">160 GB IDE DRIVE</option>
    </select> </td>
    </tr>
    <tr>
    <td><div align="right">SELECT A VIDEO CARD: </div></td>
    <td><select name="VIDEO" id="select4">
    <option value="0" selected>ON-BOARD VIDEO</option>
    <option value="50.00">64 MB AGP VIDEO</option>
    <option value="75.00">128 MB AGP VIDEO</option>
    <option value="110.00">256 MB AGP VIDEO</option>
    </select></td>
    </tr>
    <tr>
    <td><div align="right">SELECT AN OPTICAL DRIVE: </div></td>
    <td><select name="OPTICAL" id="select5">
    <option value="0" selected>NONE</option>
    <option value="25.00">CD ROM</option>
    <option value="45.00">CDRW</option>
    <option value="45.00">DVD ROM</option>
    <option value="125.00">DVD RW</option>
    </select></td>
    </tr>

    here is my output form and script:

    </FORM>

    <SCRIPT LANGUAGE="JavaScript"><!--
    function replace(string,text,by) {
    // Replaces text with by in string
    var i = string.indexOf(text), newstr = '';
    if ((!i) || (i == -1))
    return string;
    newstr += string.substring(0,i) + by;
    if (i+text.length < string.length)
    newstr += replace(string.substring(i+text.length,string.length),text,by);
    return newstr;
    }

    var passed = replace(replace(location.search.substring(1),"+"," "),"=","&");

    function split(string,text) {
    var strLength = string.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return;
    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return;
    if (i == -1) {
    splitArray[splitIndex++] = string;
    return;
    }
    splitArray[splitIndex++] = string.substring(0,i);
    if (i+txtLength < strLength)
    split(string.substring(i+txtLength,strLength),text);
    return;
    }

    //--></SCRIPT>

    <SCRIPT LANGUAGE="JavaScript1.1"><!--
    function split(string,text) {
    splitArray = string.split(text);
    splitIndex = splitArray.length;
    }
    //--></SCRIPT>

    <SCRIPT LANGUAGE="JavaScript"><!--
    var splitIndex = 0, splitArray = new Object();

    split(passed,'&');

    for (var i=0; i < splitIndex; i=i+2) {

    if (splitArray[i] == 'PROCESSOR')
    document.formname.textareaname.value = unescape(splitArray[i+1]);
    if (splitArray[i] == 'MEMORY')
    document.formname.textareaname.value = unescape(splitArray[i+1]);
    if (splitArray[i] == 'select3')
    document.formname.textareaname.value = unescape(splitArray[i+1]);

    }
    //--></SCRIPT>
    </body>
    </html>
    TOO MUCH GIDDYYUP,,, NOT ENOUGH WHOA!!!

    Trav

  2. #2
    SG Enthusiast
    Join Date
    Jan 2001
    Location
    DC
    Posts
    4,717
    I don't know JS well enough to help with actual code.

    That said, if I were using php, I would serialize the form fields taht the user inputs into a single variable and then print that to the text area form via hiddne field.

    Not sure if that piece of advice would help you, though.
    anything is possible - nothing is free


    Quote Originally Posted by Blisster
    It *would* be brokeback bay if I in fact went and hung out with Skye and co (did I mention he is teh hotness?)

Similar Threads

  1. help with data recovery
    By DAVE in forum Software Forum
    Replies: 7
    Last Post: 11-23-04, 07:36 PM
  2. PHP form not sending data
    By lance-tek in forum Programming Forum
    Replies: 4
    Last Post: 09-15-03, 08:31 AM
  3. Getting/editing form data being sent
    By tommie in forum Programming Forum
    Replies: 2
    Last Post: 04-18-03, 05:02 PM
  4. Somebody Please Explain
    By Lee_Nover in forum Broadband Tweaks Help
    Replies: 11
    Last Post: 03-24-02, 03:31 PM
  5. Security and Encryption FAQ Revision 15 by Doctor Who
    By Marine06 in forum Network Security
    Replies: 1
    Last Post: 02-19-01, 09:48 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •