SunQuest
 
           General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old March 12th, 2003, 10:27 AM
harvey_r01 harvey_r01 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Location: Bournemouth
Posts: 37 harvey_r01 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Unhappy Capturing data from form drop down list when form has not been submitted

Hello All,

I am just developing my PHP skills and was wondering if anyone can answer a problem i'm having...

I've got a PHP page that includes a form, and one of the elements on the form is a drop down list. When the user selects an option I would like the value of the option selected to go into a PHP variable, so that I can send it in a URL link.

[The Code]
<?php
$contactResults = mysql_query("SELECT * from contacts order by contactname");
?>
<td width="33%" align="center" class="place_center">
<b>Contact Details</b><br>
<select name="companycontact" onChange="">
<option value="test" selected>Contact Name</option>

<?php

do {
$options = $myrow["contactname"] . ", " . $myrow["companyname"];
printf("<option value=\"%s\">%s</option>\n", $myrow["contactid"], $options);
} while ($myrow = mysql_fetch_array($contactResults));
?>

</select><br>

<?php

echo "<a href=\"#\" onClick=\"window.open('view.contact.php?conid=" . $companycontact . "','newwindow','HEIGHT=400,WIDTH=250,left=0,top=110 ,scrollbars=1,location=1')\"><b>View Contact</b></a>";
?>

[/The_Code]

I haven't included any of my connections to the DB and the main form tag, but i don't think this is required. If this will be beneficial, please let me know and I shall post this as well...

Thanks for your help,

Harvey

Reply With Quote
  #2  
Old March 12th, 2003, 03:24 PM
jpenn jpenn is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Washington, DC
Posts: 317 jpenn User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 m 3 sec
Reputation Power: 6
Quote:
When the user selects an option I would like the value of the option selected to go into a PHP variable, so that I can send it in a URL link.


It automatically will be as when the form is submitted, the script will be able to get the value using $_POST or $_GET -> whichever your form method is set to.

So, if your 'Form Select Menu' is named 'menu' and you have an option in the 'menu' that says 'cheeseburger' and the value of that option is '1' -> when the user selects 'cheeseburger' and your form method is 'get', your php scalar will look like this ->
PHP Code:
 $_GET['menu'/* will hold a value of 1 */ 


PS: Not sure if that is what you are looking for...
__________________
~ Joe Penn

We work for free to help make this a valuable resource on the internet. Do you appreciate the help - did we provide help that will help you prosper and help that has contributed to sharpening your current skill set?

Show your appreciation and purchase something from our Amazon Wishlist's - it's simple and a great way to say thank you.




Reply With Quote
  #3  
Old March 13th, 2003, 03:06 AM
harvey_r01 harvey_r01 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Location: Bournemouth
Posts: 37 harvey_r01 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Thanks for the reply, but...

...I would like to recieve the [form] option selected before the form has been submitted. I was thinking if I could get the option selected into a PHP varable in the onChange event for the [form]SELECT menu??

Thanks for your help...

Harvey

Reply With Quote
  #4  
Old March 13th, 2003, 11:44 AM
nicat23's Avatar
nicat23 nicat23 is offline
Addicted to Chaos..
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jan 2003
Location: Ft. Worth, TX
Posts: 653 nicat23 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 47 m 52 sec
Reputation Power: 0
Send a message via AIM to nicat23 Send a message via Yahoo to nicat23
Why would you want to recieve the value of the form before it is submitted? Are you wanting to have dynamic code so that if you choose one thing, say, cheeseburger, it will make another form visible for toppings, or if you choose a taco if it gives the option of hotsauce?

The only way I could imagine for you to recieve the value is if you were using javascript and an on change to make the other form visible, if thats what you're wanting to do..

Reply With Quote
  #5  
Old March 13th, 2003, 04:21 PM
jpenn jpenn is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Washington, DC
Posts: 317 jpenn User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 m 3 sec
Reputation Power: 6
Ya - I think he might be looking for 'livescript' - asp thing, but not sure if that is exactly what it is called. I remember seeing an article on it somewhere - but can't remember where. One site that uses it is progressive.com; when filling out the auto insurance forms - the livescript tags the db to draw the info for the automobile specifics based on the selections prior...

Reply With Quote
  #6  
Old March 13th, 2003, 05:14 PM
nicat23's Avatar
nicat23 nicat23 is offline
Addicted to Chaos..
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jan 2003
Location: Ft. Worth, TX
Posts: 653 nicat23 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 47 m 52 sec
Reputation Power: 0
Send a message via AIM to nicat23 Send a message via Yahoo to nicat23
Thats what I thought but I couldn't quite place it..

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > Capturing data from form drop down list when form has not been submitted


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Iron Speed




© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway