Contact Us Forum Rules Search Archive
WebProWorld Part of WebProNews.com
Page One Link To Us Edit Profile Private Messages Archives FAQ RSS Feeds  
 

Go Back   WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Subscribe to the Newsletter FREE!


Register FAQ Members List Calendar Arcade Chatbox Mark Forums Read

Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-24-2005, 07:12 AM
dharrison's Avatar
Moderator
WebProWorld Moderator
 

Join Date: May 2005
Location: Essex, UK
Posts: 1,460
dharrison RepRank 3dharrison RepRank 3
Default Populate forms with info from previous page

Please help me.

I am carrying out some work to a customer's website and trying to make it more user-friendly.

Basically my client sells bouquets of flowers and when someone clicks that they would like to order a bouquet, she would like them to click a link that takes them through to the order form. However they would like the radio button for their required bouquet to be readily selected.

I have tried to convert her to use a shopping cart, but she is unconvinced as her customers tend to order one bouquet at a time.

Any help will be gratefully appreciated. Oh and happy thanksgiving to any of you on the other side of the pond (We only get harvest festival in September that only schools seem to celebrate)
__________________
Deb Harrison
DVH Design
Essex Web Design | Web Design Blog
Reply With Quote
  #2 (permalink)  
Old 11-24-2005, 08:18 AM
WebProWorld Member
 

Join Date: Sep 2005
Posts: 82
sysop9999 RepRank 0
Default

Not exactly sure how to read that.... do you need help in extracting the data from a form from a previous page or?
__________________
Kim B. Juul
Danish Web Design & SEO
Reply With Quote
  #3 (permalink)  
Old 11-24-2005, 09:17 AM
WebProWorld Pro
 

Join Date: Sep 2005
Location: Manchester, UK
Posts: 257
mikesmith76 RepRank 0
Default

Hi,

If you're using some kind of server side scripting language you could simply pass the id of the required bouquet as part of the query string for the link (eg index.php?bid=1). Thats assuming each bouquet has a unique id. On the next page you can pick up this id and decide which radio button to select based on it.

Mike
Reply With Quote
  #4 (permalink)  
Old 11-24-2005, 09:18 AM
dharrison's Avatar
Moderator
WebProWorld Moderator
 

Join Date: May 2005
Location: Essex, UK
Posts: 1,460
dharrison RepRank 3dharrison RepRank 3
Default

No the other way around: Clicking the order form link from a product page and the link/script somehow containing the information to populate the form (in this case, checking the appropriate radio button.

So for example if you were looking at the 'lilies' page and you decide you want to buy some lilies, you click the 'order Lilies' button which takes you through to the order form with the 'Lilies bouquet' radio button checked, so all you have to do is fill in your details.

There are a lot of programs online for extracting data from forms, but I am looking for the reverse.

Does that make sense?

Sorry. Thanx Mike your reply came through just as I was sending this. Do you have an example script to pick up the ID on form page?
__________________
Deb Harrison
DVH Design
Essex Web Design | Web Design Blog
Reply With Quote
  #5 (permalink)  
Old 11-24-2005, 09:24 AM
WebProWorld Pro
 

Join Date: Sep 2005
Location: Manchester, UK
Posts: 257
mikesmith76 RepRank 0
Default

What language would you be using? i know my way around php and asp, assuming the link index.asp?bid=1 in asp you can use

Response.Write Request.QueryString("bid")

In PHP it would be

echo $_GET['bid'];

Both will output the value of bid to the screen.
Reply With Quote
  #6 (permalink)  
Old 11-24-2005, 10:46 AM
dharrison's Avatar
Moderator
WebProWorld Moderator
 

Join Date: May 2005
Location: Essex, UK
Posts: 1,460
dharrison RepRank 3dharrison RepRank 3
Default

Thanx Mike

I'd say I'd be using PHP.

Would the script check the radio buttons?

Forgive my naivety, but PHP is still quite new to me.
__________________
Deb Harrison
DVH Design
Essex Web Design | Web Design Blog
Reply With Quote
  #7 (permalink)  
Old 11-24-2005, 10:52 AM
ADAM Web Design's Avatar
WebProWorld 1,000+ Club
 

Join Date: Dec 2003
Location: Toronto, Ontario, Canada
Posts: 2,217
ADAM Web Design RepRank 0
Default

I don't know the PHP way, Debbie. But in ASP, I can at least give you the concept that I use.

Basically, I gather up all of the form data sent to me via post (no querystrings, since if you I hidden fields, the user can alter the data post facto).

So here's how it works in ASP (the simple coding):
Code:
<%
Dim Some_Field
Some_Field = Request.Form ("Some_Field")

...
%>
<input type="text" name="Some_Field" value="<% = Some_Field %>" />
The first time around, since there's nothing from your form post, ntohing will be assigned to the value.

The second time around, whatever you put in the Some_Field field will appear in the field.

Personally, I prefer to gather form elements to variables since that way, I can populate a form with either values retrieved from a database or form posts or even querystrings on rare occasions, depending on how I choose to set it up.
Reply With Quote
  #8 (permalink)  
Old 12-13-2005, 09:11 AM
dharrison's Avatar
Moderator
WebProWorld Moderator
 

Join Date: May 2005
Location: Essex, UK
Posts: 1,460
dharrison RepRank 3dharrison RepRank 3
Default

Is there a way to accomplish this using Javascript?

On my travels into Cyberspace, I have come across

http://www.webreference.com/programm...t/jf/column11/

Which is almost the same thing but with the previous page instead of the pop-up window.

Any help will br gratefully received.

Thanx.
__________________
Deb Harrison
DVH Design
Essex Web Design | Web Design Blog
Reply With Quote
  #9 (permalink)  
Old 12-13-2005, 11:08 AM
WebProWorld Pro
 

Join Date: Aug 2004
Location: Maryland
Posts: 219
webmasterjunkie RepRank 0
Default

Here is how it would basically work in PHP:
Code:
<?php
if (isset($_POST['flowers'])) {
	$flower_type = $_POST['flowers'];
	echo "Your customer wants to buy $flower_type";
} else {
	echo "
<form name='flower_type' method='post' action='$PHP_SELF'>
  


    <label>
    <input type='radio' name='flowers' value='Lillies'>Lillies</label>
    

    <label>
    <input type='radio' name='flowers' value='Daffodils'>Daffodils</label>
    

  </p>
</form>";
}
?>
That would be one way to handle your problem.
Reply With Quote
  #10 (permalink)  
Old 12-13-2005, 12:37 PM
dharrison's Avatar
Moderator
WebProWorld Moderator
 

Join Date: May 2005
Location: Essex, UK
Posts: 1,460
dharrison RepRank 3dharrison RepRank 3
Default

Thanks for your help WMJ :)

If say the form was on a separate page to the order buttons, how would this be achieved?

Sorry to be a pain.

Many thanx & best regards
__________________
Deb Harrison
DVH Design
Essex Web Design | Web Design Blog
Reply With Quote
  #11 (permalink)  
Old 12-13-2005, 12:55 PM
WebProWorld Pro
 

Join Date: Aug 2004
Location: Maryland
Posts: 219
webmasterjunkie RepRank 0
Default

NP, glad I could answer instead of ask for once. Anyway:
Code:
<?php
   echo "
<form name='flower_type' method='post' action='review.php'>
  


    <label>
    <input type='radio' name='flowers' value='Lillies'>Lillies</label>
    

    <label>
    <input type='radio' name='flowers' value='Daffodils'>Daffodils</label>
    

  </p>
</form>";
?>


<?php
if (isset($_POST['flowers'])) {
   $flower_type = $_POST['flowers'];
   echo "Your customer wants to buy $flower_type";
} else {
   echo "You must choose a flower type, please go back."
}
?>
Again, that's very basic, but I hope you get the general idea. When you make your form, just make sure you name your fields nicely. Then when they submit the form, just call the form field name with the $_POST like I used above.
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Tags: , , , ,



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Search Engine Optimization by vBSEO 3.2.0