www.webdeveloper.com
Results 1 to 11 of 11

Thread: Display results

  1. #1
    Join Date
    Mar 2004
    Posts
    7

    Question Display results

    I might not posted the topic on the right forum, sorry for that.

    I am building a form that will check if a domain is available. Simple, with one text box and a submitt button.

    I want to display the text box in the result page. Anyone any clue on how to do it, with simple forms instead of using php or anything else.

    So, the input by the visitor should appear again at the results page.

    Thanks a lot for your assistance.

  2. #2
    Join Date
    Jul 2003
    Location
    Boston Area, Massachusetts
    Posts
    3,489
    Welcome to the forums.

    This could be done quite easily. Assuming you're using PHP, you could merely pass the variable across to the next page (actually, accessing it using the $_POST array) and set it as the value for the form element in the next page. It'd be something like this:
    • index.html
      Code:
      <form action="foo.php" method="post">
      	<div>
      		<input type="text" name="query" />
      		<input type="submit" value="Submit" />
      	</div>
      </form>
    • foo.php
      Code:
      <form action="foo.php">
      	<div>
      		<input type="text" name="query" value="<?php echo $_POST['query']; ?>"/>
      		<input type="submit" value="Submit" />
      	</div>
      </form>
    Last edited by fredmv; 03-09-2004 at 11:03 AM.

  3. #3
    Join Date
    Mar 2004
    Posts
    7
    that's the point, I am not using php.

    Could I just create these two php pages without setting up database etc?

    Or else, do you have a solution for plain html?

  4. #4
    Join Date
    Jul 2003
    Location
    Boston Area, Massachusetts
    Posts
    3,489
    While you could use JavaScript to do this, you shouldn't; users without JavaScript then do not get this functionality where they could if you did it server-side. To answer your question: of course. PHP does not require a database to be used; it's only when you need one (e.g., to query the database somehow).

  5. #5
    Join Date
    Mar 2004
    Posts
    7
    Do you have that javascript available by any chance.

    I will try to get it done by php, but just in case?

    thanks a lot.

  6. #6
    Join Date
    Mar 2004
    Posts
    7
    I've tried your code, but it display only the result in the title bar of I.E. I need it to be displayed in the screen.

    So, in a text box, they enter a value. Then, they submit and a result appears. Alongside, I want the initial input value displayed on that "results page."

    thanks,

  7. #7
    Join Date
    Jul 2003
    Location
    Boston Area, Massachusetts
    Posts
    3,489
    You bet; it'd be done in JavaScript like this:
    • pagea.html
      Code:
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
      	   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
      
      <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
      	<head>
      		<title>untitled</title>
      		<meta http-equiv="content-type" content="application/xhtml+xml; charset=iso-8859-1" />
      		<script type="text/javascript">
      		//<![CDATA[
      			function setName()
      			{
      				window.name = document.forms[0][0].value;
      				return true;
      			}
      		//]]>
      		</script>
      	</head>
      	<body>
      
      		<form action="pageb.html" onsubmit="return setName();">
      			<div>
      				<label for="query">
      					Query:
      					<input type="text" name="query" />
      				</label>
      				<input type="submit" value="Submit" />
      			</div>
      		</form>
      
      	</body>
      </html>
    • pageb.html
      Code:
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
      	   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
      
      <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
      	<head>
      		<title>untitled</title>
      		<meta http-equiv="content-type" content="application/xhtml+xml; charset=iso-8859-1" />
      		<script type="text/javascript">
      		//<![CDATA[
      			onload = function() { document.forms[0][0].value = name; }
      		//]]>
      		</script>
      	</head>
      	<body>
      		<form action="pageb.html">
      			<div>
      				<label for="query">
      					Query:
      					<input type="text" name="query" />
      				</label>
      				<input type="submit" value="Submit" />
      			</div>
      		</form>
      		<hr />
      		<p>Some results from the search here.</p>
      	</body>
      </html>
    Though note, if PHP is available, it should be used; that way, it'd work for everyone regardless of support for JavaScript, and it'd probably be easier to implement.

  8. #8
    Join Date
    Mar 2004
    Posts
    7
    Thanks, the javascript did the job.

    Can you tell me what I can do in the javascript, to have multiple lines copied. The code you provided delivers one item to the next page, but I would like to have a checkbox copied as well.

    thanks again,

  9. #9
    Join Date
    Jun 2003
    Location
    The United States Site: http://kellyj.t35.com
    Posts
    2,561
    you might be better off if you need many items sending them through the url, like ...pageb.html?number=7&letter=d. And then on the second page, you can retrieve those values. If interested, I have a script that will do this for you and will be happy to post it!

  10. #10
    Join Date
    Jul 2003
    Location
    Boston Area, Massachusetts
    Posts
    3,489
    If you decide to go the query string route, see: http://www.webdevfaqs.com/javascript.php#querystring.

  11. #11
    Join Date
    Mar 2004
    Posts
    7
    2 steelersfan88

    Yes please, I would be very interested in looking at that script.

    thanks both for replying so quickly.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles