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.

HTML Forum


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



Post a Project »

Find a Professional HTML Freelancer!

Find a Freelancer to help you with your HTML projects

FREE Outsourcing eBook!

Reply
Old 11-09-2004, 05:09 AM Calling a function
Brufton's Avatar
Super Talker

Posts: 101
Location: Dover, Kent (UK)
Trades: 0
Hi all, but of a problem here.
I'm using a drop down list, and want to call a function when the user selects a value.

"function($variable_here) {
bits and bobs here
}
<form name='select_user'><select name='user' onChange='function(user.value)'> <option>Select User</option><option value='1'>Admin</option></select></form>"

I'm using PHP to do the function bits and bobs, but can't get it to call the function and process the data
Brufton is offline
Reply With Quote
View Public Profile Visit Brufton's homepage!
 
 
Register now for full access!
Old 11-09-2004, 06:45 AM
Minaki's Avatar
Defies a Status

Posts: 1,626
Location: Guildford, UK
Trades: 0
You can't call a PHP Function directly from the onChange event of a drop down list like that. (PHP happens server side, before the page is sent to the client, the onChange event happens on the client side, the server has already sent the page and isn't worrying about it any more.)

You have two options, depending on what it is you want to do. You could write the function in JavaScript, but bear in mind if you're doing authintication orientated things it won't be very secure.

Your other option is to write a small JavaScript function to refresh the page and add the value as a query string (or form value), then in the PHP script, check to see if that value exists, then execute the code from there.

I can't give you a full working example because I don't do PHP.
__________________
Minaki Serinde MCP
"Wow, Linux is nearly on-par with Windows ME!"

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
Minaki is offline
Reply With Quote
View Public Profile Visit Minaki's homepage!
 
Old 11-09-2004, 07:49 AM
Brufton's Avatar
Super Talker

Posts: 101
Location: Dover, Kent (UK)
Trades: 0
Look's like I'll have to do the second option, as I want to load data from a database (MySQL) when a user selects a client from the list.
Brufton is offline
Reply With Quote
View Public Profile Visit Brufton's homepage!
 
Old 11-09-2004, 09:04 AM
Brufton's Avatar
Super Talker

Posts: 101
Location: Dover, Kent (UK)
Trades: 0
How can I get the browser to automatically select the option that the user selected, after the page has been refreshed?
(ie, the user selects, eg the 3rd option; then the page refreshes, what code do I need for the browser to re-select the 3rd option)?

When I used Visual Basic, you ran a line of code something along the lines of "List1.ListIndex = 3". Is there something similar in HTML, perhaps users.listindex = "3"?
Brufton is offline
Reply With Quote
View Public Profile Visit Brufton's homepage!
 
Old 11-09-2004, 09:14 AM
Brufton's Avatar
Super Talker

Posts: 101
Location: Dover, Kent (UK)
Trades: 0
Don't worry, I've used a script in PHP to select the id, by using entering "selected" into the <option> header if the id matches that of the submitted one.
Brufton is offline
Reply With Quote
View Public Profile Visit Brufton's homepage!
 
Reply     « Reply to Calling a function
 

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 1.07746 seconds with 12 queries