Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 15 of 15
  1. #1
    New to the CF scene
    Join Date
    Dec 2002
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    display form results in a textbox

    hello --

    im new to javascript ....

    anyway, im creating a form .... checkboxes, radio buttons, textboxes etc ....

    onSubmit - i created a new window that displays the information that was selected from the form ....

    the new window displays everything i selected just fine.

    currently all information that displays on the new window is just text that cant be changed or updated.

    how can i change this so that the results show in a "textbox" (instead of plain text) so the user could say change the information or something???

    im not using any cgi or php to submit the results or anything ....

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You have a form with multiple controls (text inpute, checkboxes, etc) and you would like to show the results in a SINGLE textarea? Do I get you right?

    Or do you want only the data they entered to re-appear in a similar form control on the new page, so that it can be edited and re-submitted (confirmed)?
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”

  • #3
    New to the CF scene
    Join Date
    Dec 2002
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    "Or do you want only the data they entered to re-appear in a similar form control on the new page, so that it can be edited and re-submitted (confirmed)?"


    yes this is what i want .......

  • #4
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Oooh. I'd seriously consider giving the user a confirm message instead first.

    <form ... onsubmit="return confirm('Are you sure the data you entered is accurate and complete?');" ... >

    What you ask for CAN be done, but is no simple task, and could take several hours to accomplish. Sorry, I just don't do that kind of work unless I'm supremely interested in the result or I'm being paid, and I'm not THAT intersted in the result
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”

  • #5
    New to the CF scene
    Join Date
    Dec 2002
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ok let me simplify what im looking to do ......

    lets take a form with one textbox where the user enters a quanity.......

    at this present time i can show the results of the quanity on a new window that opens up but it is displayed in a plain text form that can not be manipulated ......

    id like to have that one textbox quanity display on that new window in a textbox (instead of plain text) so the user can change the quanity ....

    can anyone help me?

  • #6
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Sure. I'm assuming you are using GET method forms and for this example, assume that your quantity field is named "quantity"

    in the popup page
    Code:
    <html>
    <head>
    <title>Whatever</title>
    <script type="text/javascript">
    function parseGetVars() {
    	var getVars = new Array();
    	var qString = top.location.search.substring(1);
    	var pairs = qString.split("&");
    	var nameVal, val;
    	for (var i=0; i<pairs.length; i++) {
    		nameVal = pairs[i].split("=");
    		val = (typeof nameVal[1] == 'undefined') ? '' : unescape(nameVal[1]);
    		getVars[unescape(nameVal[0])] = val;
    		}
    	return getVars;
    	}
    var _GET = parseGetVars();
    
    function setFormValues(f) {
    	f.qty.value = _GET['quantity'];
    	}
    
    </script>
    </head>
    
    <body>
    <form method="GET" onload="setFormValues(this);">
    <input type="text" name="qty" />
    </form>
    </body>
    </html>
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”

  • #7
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have a strange sense of dejavu...

    (Which usually means if you had searched the forums, you may have found the answer yourself. ).

    There's even a tutorial for this here:

    http://www.javascriptkit.com/javatutors/send1.shtml

    although I think that beetle's solution (and mine) are much easier to implement (and very similar)... i.e.:

    Code:
    <script type="text/javascript">
    <!--
    function QueryString(str){
       var q = window.location.search;
       var foundValue = ""
       if(q.length > 1){
          this.q = q.substring(1, q.length);
       }
       this.keyValuePairs = new Array();
       if(q){
          for(var i = 0; i < this.q.split("&").length; i++){
             this.keyValuePairs[i] = this.q.split("&")[i];
             if(this.keyValuePairs[i].split("=")[0] == str){
                foundValue = unescape(this.keyValuePairs[i].split("=")[1]);
             }
          }   
       }
       return foundValue;
    }
    //-->
    </script>
    Last edited by whammy; 12-05-2002 at 02:13 AM.
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #8
    New to the CF scene
    Join Date
    Dec 2002
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    well i do thank the 2 people that took the time to offer help ...

    id like to add that i started out with the words "im new to javascript" ..... which means im learning, and im trying real hard ...

    however, the 2 posters kinda came off snooty and made me feel like a idiot .....

    before i posted on here i searched this site for well over an hour ... im new, so maybe i didnt know where to search etc......

    anyway, im frustrated cause i still cant get the code working

  • #9
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    I'm wondering why you would display again the form in a new window then let the user edit the inputs in that new window.
    You can just ask the user the confirmation if the entered data in the main window are correct. So beetle's original solution would suffice:
    <form ... onsubmit="return confirm('Are you sure the data you entered is accurate and complete?');" ... >
    ...
    <input type="submit" value="Submit">
    </form>

    No need for the new window. The user can change the data he entered by choosing the Cancel button in the confirm box.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #10
    New to the CF scene
    Join Date
    Dec 2002
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks glen ...

    i do need a confimation window..... trust me lol

    i simply want to know how to display the results - such as a quantity of an item - in a new confirmation window but in a textbox instead of just plain text .....

    the site is spread out .....so i DO need to have a new window like this ... tough to explain i guess - but it only makes sense for the user

    thanks cindy

  • #11
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    ok, can you show some of your code that displays just plain text?
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #12
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    First of all, I want to apologize for myself AND beetle, if you read our comments as "snooty", I know mine were intended to help, and I'm sure beetle's were too.

    I'm not totally sure about beetle's script since I haven't messed around with it, but with mine you'd want the code I posted to be in the second page, and make sure in the first page you are using:

    <form method="get" action="yournextpage.htm">

    (The only way javascript can pass values from page to page is to use the "get" method, which gives the page that it posts to a querystring). What that does, is it puts all of the form values you're using on the first page into the URL of the second page, like:

    http://www.whatever.com/somepage.ext?name=value&name2=value2

    The part bolded above (which I'm sure you've seen on many sites), is called the "querystring".



    On the second page (assuming you included the script I posted), you could get any variable's value from the querystring by using:

    <input type="text" name="blah" value="QueryString('blah')" />

    where "blah" is the "name" in the querystring, the QueryString() function will return the value, if it exists.

    Hope this helps.

    P.S. The tutorial I posted should also give you more information on this kind of technique - and it's a must read, especially if you're new to javascript!

    You should never feel like an idiot though, and don't be afraid to ask any questions here at all - everyone is new to javascript at one point.

    That's what we're here for! Believe me, I still have quite a bit to learn about javascript and a few other programming languages to boot. You never stop learning, you can only get better.
    Last edited by whammy; 12-06-2002 at 01:57 AM.
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #13
    New to the CF scene
    Join Date
    Dec 2002
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thank you whammy ...

    anyway, i found a much easier way to create a new window and have the results displayed in a textbox in that new window ....

    ///////////////////////////////////////////////////////////////////////////////


    function viewShoppingCart(){

    results = window.open("", "results","toolbar=1,status=0,width=400,height=400");
    parent.results.document.open("text/html");
    parent.results.document.write("<html><head><title>profile</title><form name='form2' method='POST'></head><body> ");

    displayItems();

    parent.results.document.write('<center><p><a href="javascript:close();">Close Window</a></p></center></body></form></html>');
    parent.results.document.close();
    }

    ///////////////////////////////////////////////////////////////////////////
    in the function called displayItems(); .... i can then use code
    such as below which takes the value of a textbox, radio button, whatever..... from the main form to the new window form .... seems much easier to me!!

    parent.results.document.write("book #1: <input type='text' name='book12'>");

    parent.results.document.form2.book1.value = document.Form1.book1.value;

    ///////////////////////////////////////////////////////////////////////////

  • #14
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That will work, until you decide you don't want a popup and make it just a regular link. I'm not saying that will happen, of course, but the method whammy and I outlined will work for both

    Here is a thread where I helped an individual implement my parseGetVars function, and shows examples of how it can be used to put the data anywhere on the page: as text, in form controls, or even for the document title.
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”

  • #15
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Oh, and apologies, after looking back I realize my last examlpe had some errors. Here's one I tested.
    Code:
    <html>
    <head>
    <title>Whatever</title>
    
    <script type="text/javascript">
    
    function parseGetVars() {
    	var getVars = new Array();
    	var qString = top.location.search.substring(1);
    	var pairs = qString.split("&");
    	var nameVal, val;
    	for (var i=0; i<pairs.length; i++) {
    		nameVal = pairs[i].split("=");
    		val = (typeof nameVal[1] == 'undefined') ? '' : unescape(nameVal[1]);
    		getVars[unescape(nameVal[0])] = val;
    		}
    	return getVars;
    	}
    
    function setFormValues(f) {
    	var _GET = parseGetVars();
    	f.qty.value = (typeof _GET['quantity'] != 'undefined') ? _GET['quantity'] : "";
    	}
    
    </script>
    </head>
    
    <body onload="setFormValues(document.forms[0]);">
    <form method="GET">
    <input type="text" name="qty" />
    </form>
    </body>
    </html>
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”


  •  

    Posting Permissions

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