Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Coding Forum


You are currently viewing our Coding Forum as a guest. Please register to participate.
Login



Reply
How to select from a dynamically generated list and pop that info into an input field
Old 01-15-2009, 04:16 PM How to select from a dynamically generated list and pop that info into an input field
Average Talker

Posts: 26
Trades: 0
First post on this site but it looks like a busy forum.. so hope I'll be a regular in here!

Anyway... I have a website with a registration page that i need to be able to select some of the input fields from a dynamically (mysql) generated list of options... Is this possible without the use of JS?

Hope sum1 can help me.. i have looked for a solution online but i think i'm using the wrong wording to get the solution?

Merci
PauloMillerz is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 01-15-2009, 06:28 PM Re: How to select from a dynamically generated list and pop that info into an input f
angele803's Avatar
Perfectly Imperfect

Posts: 1,774
Name: Stephanie
Location: Oklahoma
Trades: 2
If I understand correctly, you will need some server side code to do this (such as php). I don't think you can talk to a database with javascript.
__________________

Please login or register to view this content. Registration is FREE
angele803 is offline
Reply With Quote
View Public Profile
 
Old 01-16-2009, 09:15 AM Re: How to select from a dynamically generated list and pop that info into an input f
Average Talker

Posts: 26
Trades: 0
Quote:
Originally Posted by angele803 View Post
If I understand correctly, you will need some server side code to do this (such as php). I don't think you can talk to a database with javascript.
Maybe i didn't explain it too well

Right, i've set up a form page in html with simple input and submit fields etc etc.. This form is writing to a database with player names (it's a fantasy football website in UK, lol, soccer), and this is working fine if you type in the player names manually..

Now... i have a list of players which is dynamically generated. That on it's own is working fine.

So basically what i need to do is bring these 2 working systems together so I can click a button in the form to bring up the list, select a player from the list, and it puts that name in the field of the form...??

lol.. i hope i have explained this better?? I'll have to try and get an example for you otherwise...

any help appreciated....
PauloMillerz is offline
Reply With Quote
View Public Profile
 
Old 01-16-2009, 02:46 PM Re: How to select from a dynamically generated list and pop that info into an input f
angele803's Avatar
Perfectly Imperfect

Posts: 1,774
Name: Stephanie
Location: Oklahoma
Trades: 2
If you can dynamically populate a list of the player's names, you can populate a form drop down list. You would need to make to sure populate the values in that drop down list too, so they will be passed.
What language are you using?

In coldfusion, it would be something like this:
Code:
<form>
	<select name="players">
		<cfoutput query="qPlayerNames">
			<option value="#playersName#">#PlayersName#</option>
		</cfoutput>
	</select>	
</form>
__________________

Please login or register to view this content. Registration is FREE
angele803 is offline
Reply With Quote
View Public Profile
 
Old 01-16-2009, 02:49 PM Re: How to select from a dynamically generated list and pop that info into an input f
Average Talker

Posts: 26
Trades: 0
Quote:
Originally Posted by angele803 View Post
What language are you using?
HTML for my form, PHP for my list (and parts of the html) and mysql
PauloMillerz is offline
Reply With Quote
View Public Profile
 
Old 01-16-2009, 02:50 PM Re: How to select from a dynamically generated list and pop that info into an input f
Average Talker

Posts: 26
Trades: 0
Quote:
Originally Posted by angele803 View Post
If you can dynamically populate a list of the player's names, you can populate a form drop down list. ]
That would work if it was only 1 column of data though? How about more than 1?
PauloMillerz is offline
Reply With Quote
View Public Profile
 
Old 01-16-2009, 03:04 PM Re: How to select from a dynamically generated list and pop that info into an input f
VirtuosiMedia's Avatar
Web Design Made Simple

Posts: 1,228
Trades: 0
You would use JavaScript for this. In pseudo-code, you would need to do the following:
  1. Detect the onclick event for your drop-down select box
  2. Within the event, get the value of the option that is selected
  3. Set the value of the text input element to the value retrieved from the select box
If you absolutely don't want to use JavaScript, you would need a two-part form in which the select value is passed to the second part of the form as POST or GET data or through a session variable.

As a side note, you may have a design issue. If you are already selecting a player from a list, why does a text input need to be populated with the same information? You basically have two form elements doing the same task.
__________________
Want new web resources every day? - Follow me on
Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Last edited by VirtuosiMedia; 01-16-2009 at 03:08 PM..
VirtuosiMedia is offline
Reply With Quote
View Public Profile Visit VirtuosiMedia's homepage!
 
Old 01-16-2009, 03:07 PM Re: How to select from a dynamically generated list and pop that info into an input f
Average Talker

Posts: 26
Trades: 0
Quote:
Originally Posted by VirtuosiMedia View Post
You would use JavaScript for this. In pseudo-code, you would need to do the following:
  1. Detect the onclick event for your drop-down select box
  2. Within the event, get the value of the option that is selected
  3. Set the value of the text input element to the value retrieved from the select box
If you absolutely don't want to use JavaScript, you would need a two-part form in which the select value is passed to the second part of the form as POST or GET data or through a session variable.
Only reason i didn't really wanna use JS is because it's one of the scripting methods i've not had any experience with.. any good tutorials u can suggest?
PauloMillerz is offline
Reply With Quote
View Public Profile
 
Old 01-16-2009, 03:20 PM Re: How to select from a dynamically generated list and pop that info into an input f
VirtuosiMedia's Avatar
Web Design Made Simple

Posts: 1,228
Trades: 0
If you're just getting into it, jQuery would probably be a good place to start. It's a JavaScript framework that has a fairly robust user community and makes JavaScript fairly simple. Once you get a handle on it, you might want to try MooTools, which is my personal favorite but a little more complicated in some respects.

JavaScript might be a little intimidating at first, but if you're working on the web, it's almost an essential. Tizag has a series of tutorials and I've also found Douglas Crockford's video series very useful as well. Quirksmode is also a great resource for browser compatibility issues, but the frameworks should take care of most of that for you.
__________________
Want new web resources every day? - Follow me on
Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
VirtuosiMedia is offline
Reply With Quote
View Public Profile Visit VirtuosiMedia's homepage!
 
Old 01-16-2009, 03:23 PM Re: How to select from a dynamically generated list and pop that info into an input f
Average Talker

Posts: 26
Trades: 0
Bonus.. thanks for that... yea i was aware that i would prob need to learn JS when i started this project.. just trying to be lasy.. lol...

Thanks for the advice everyone.. of to get some sleep then up bright and early in the morning to crack on wiv this lickle baby!!! lol thanks agen
PauloMillerz is offline
Reply With Quote
View Public Profile
 
Old 01-16-2009, 04:46 PM Re: How to select from a dynamically generated list and pop that info into an input f
angele803's Avatar
Perfectly Imperfect

Posts: 1,774
Name: Stephanie
Location: Oklahoma
Trades: 2
I don't think you would have to use javascript for this. You can select and use more than one column of data. You could even do two separate queries to get the data. Can you post the code you are using to dynamically populate the list of players? If so, I may be able to help you make it work for a drop down list. It really shouldn't be too hard and you shouldn't have to use javascript.

*Note: Im not against javascript and VirtuosiMedia's suggestion sounds as though it would work, but I just don't think you need to do that extra step.
__________________

Please login or register to view this content. Registration is FREE
angele803 is offline
Reply With Quote
View Public Profile
 
Old 01-17-2009, 05:56 AM Re: How to select from a dynamically generated list and pop that info into an input f
Average Talker

Posts: 26
Trades: 0
Thanks angele803 for that but i prob should start using JS anyway for things so this could be a good starter for me. i'll let u all know how i get on.
PauloMillerz is offline
Reply With Quote
View Public Profile
 
Old 01-18-2009, 10:39 AM Re: How to select from a dynamically generated list and pop that info into an input f
Average Talker

Posts: 26
Trades: 0
Struggling to get to grips with the Javascript element of it. I understand the logic.. just dunno how to implement what i wanna do to it.. I need to bring the 2 types of data together client side. I.e. I need to be able to select which position to swap, and select which player to place in that position. I see logically that this needs to happen client side because the server side php element cannot work with client side changes.

Once this done client side it can be sent off to the server to change the database, that bit i get lol...

Any ideas? I'm going to keep banging my head until something goes in though.. any help appreciated...

Last edited by PauloMillerz; 01-18-2009 at 10:40 AM..
PauloMillerz is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to How to select from a dynamically generated list and pop that info into an input field
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.36835 seconds with 12 queries