Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

create html page from a form 1

Status
Not open for further replies.
Feb 12, 2002
80
NO
I want to take the data entered in one html page and create a second page using that data.
I have searched for information about forms, and feel comfortable setting up a page with forms on for the user to enter the data, but I don't understand where I send that data then. How do I receive the subitted data and use it on my second html page?

I'm comfortable using html and javascripts - ideally I'd set some variables using the data sent.

I'm basically wanting to create some tape labels. The data on these could be selected from radio buttons, drop down lists etc in a form (including how many labels are needed). Submitting this would then create a printable page with that number of labels on, with the data on them taken from the forms.

Any advice or address of a good tutorial would be appreciated.
 
I've found this page:
Javascript > FAQ's > #26. Sending data between pages

But now I don't know how to use the data on the second page!
I can send the data, but don't know how to store it into variables on my second page to display on the page!

So if I had a drop down list on page one, the user selects one item then submits and it sends the value in the drop down list with the URL - and then reads that in and uses it in the second page.

Does anyone know what I mean?!
 
I can recommend to use hidden form fields to store the values passed from the 1st page.
You can even create a full copy of the original form if you want, and store the selected options and enteres values there:

<input type=&quot;hidden&quot; name=&quot;select1&quot; value=&quot;option2&quot;>
This field stores the selectes option from drop-down list.
 
I was looking for something similar but found it very difficult to get any good scripts.

I needed a multiple page script where I could collect user information over 3 pages before submitting it with the final form.
The closest I got was Alienform, I never actually got this working though!

If you modify this you should be able to carry information over one page and write it to another.

The guys in the Cgi or Perl forums should be able to help you.


É

endamcg-logo1b.gif

 
I'm trying to use form fields and pass the values over to the next page ... but am still struggling.
Do you know of any REALLY SIMPLE example pages of entering data on one page and it altering the following page accordingly. It could just be really simple, and I'm sure I could build on that. But I need somwewhere to start.
If anyone could send me the basics of two pages, one submitting data to another then that would be great.

Ideally as a string from one text box and one drop down list and send it to the main body of the second page.

Anyone?
Thank you.
 
It's really easy in php!

Page1.php:
---------------------
<form action=&quot;page2.php&quot;>
<input type=&quot;hidden&quot; name=&quot;date&quot; value=&quot;<?=date(&quot;Y-m-d&quot;)?>&quot;>
<input type=&quot;text&quot; name=&quot;body&quot;>
</form>
---------------------

page2.php:
---------------------
<?
print($date);
print($body);
?> It's a pleasure to know that I've helped you. If I have,
please click the link below to let me know. :)
 
I cannot get php to work - I guess our server may not support it (is this possible?).
When I try your example, I end up with the following line in the address bar:
page_2.php?date=%3C%3F%3Ddate%28&body=2002-12-24
(where &quot;2002-12-24&quot; is wwhat I entered in the text field) and nothing being displayed in the window.

Is it really that difficult to pass information from one window to another?
What about something along the lines of
<a href=&quot;nextPage.htm?my_variable=my_value>&quot;
How do I read this into the receiving page (&quot;nextPage.htm&quot;)?
 
Yes. You can pass values like that, but but the problem is reading them. As far as I know, you can't do that in javascript. You have to have a server side script to process the info. PHP might not be installed. Do you have ASP?

Rick It's a pleasure to know that I've helped you. If I have,
please click the link below to let me know. :)
 
You CAN do it with javascript if you pass vars/values through URL string.
There are some very useful threads about it in this forum, but I don't remember exactly how to find them (search for posts for February-April period).

This is a script that reads only one value that is passed:

function searchIt() {
value = document.location.search;
// &quot;?searchfor=&quot; = 11 chars
value = value.substring(11, value.length);
return(value);
}

Let's say you have constructed such URL:
somepage.html?searchfor=aaaa

Here [tt]searchfor[/tt] is a variable name, and [tt]aaaa[/tt] is it's value.
Function searchIt() reads the URL string and returns the value passed. Then you can use it as you like.

The case with many variables is more complicated one (and maybe not so simple as you think). Use the split() that creates an array with values extracted from URL string.

good luck
 
Thank you for your responses - it looks to me like the passing of variables through a URL string is the best option. I looked into this before and got confused at the reading values back in part.
I think I should getit now, using an array to split the values coming in on the &quot;&&quot; and then split the elements of the array on the number of characters each variable name has (as long as I know which order they will come in).
Does that make sense?
It does to me (at the moment!) - I'll work on this and hopefully get it to work!!
Thank you all for your time and thoughts,
Tim
 
!!!
Right - I seem to have grasped the idea that you can pass variables from one window to another using URL string.
Now all I need to do is work out how to get my variables into the URL string!
I tried setting a variable, then putting that variable into the URL, like so:

Code:
selected_colour=red;
then
Code:
<a href=&quot;page.htm?colour=selected_colour&quot;></a>

but this just passed &quot;selected_colour&quot; as the variable name, not &quot;red&quot;.

Am I barking up the wrong tree?
 
I'm getting closer ...
I now have the following in the head of the page:
Code:
my_val = 200;

function make_link(){
 document.write('<a href=&quot;next_page.htm?my_variable='+my_val+'&quot;>Click here</a>');
}
and
Code:
<script>make_link()</script>
in the body. Then in &quot;next_page.htm&quot; I have the code suggested by Starway above.
This seems to work well.
So now I just need to be able to set the variables from the items selected from the drop down menus and work out how to get rid of &quot;%20&quot; in the string.

Thank you for your help.
Tim
 
For solving &quot;%20&quot; issue you can use escape() and unescape() javascript functions.

good luck
 
Hi,
Well I have all this sorted out now - eventually, thanks to your help.

I used forms to get the user to select the data, then used the submit button on the form to call the following function:
Code:
function setVariables(){
 my_variable=document.myForm.my_text_box.value;
  make_link(my_variable);
}
which calls the following function:
Code:
function make_link(var_1){
  document.write('<a href=&quot;next_page.htm?the_variable='+var_1+'&quot;>Click</a>');
}
and then in the &quot;next_page.htm&quot; I had the code I found at the following link:
All this works a treat. I also used the unescape() function to get rid of the
Code:
%20
.

Thank you for your help. You're a credit to this site.
Tim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top