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.

PHP Forum


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



Freelance Jobs

Reply
New To PHP - Need help with conditional statements.
Old 01-24-2011, 01:42 PM New To PHP - Need help with conditional statements.
mb2000inc's Avatar
Extreme Talker

Posts: 150
Name: Mark
Location: Ohio
Trades: 0
Hi.
I'm trying my hand at PHP.... I'm usually a dot net kinda guy.

I want to do a simple IF statement.
If a dropdown list A's value = "1", then textbox B's value = "Something".

suggestions?
__________________
Need a vacation.
mb2000inc is offline
Reply With Quote
View Public Profile Visit mb2000inc's homepage!
 
 
Register now for full access!
Old 01-24-2011, 02:17 PM Re: New To PHP - Need help with conditional statements.
mb2000inc's Avatar
Extreme Talker

Posts: 150
Name: Mark
Location: Ohio
Trades: 0
What about a SWITCH?

Would this work?
If the value of a dropdown is one thing, then assign a value to a textbox accordingly...?

Please, I am new to this - and whatever insight you can give me would be helpful....
Code:
<?php
	$dept = ['department_id'];
	$UID = ['unique_identifier']
	switch ($dept) {
		case 9:
			$UID = "foo"
			break;
		case 8:
			$UID = "blah"
			break;
		case 7:
			$UID = "blargh"
			break;
		case 10:
			$UID = "thing"
			break;
	endswitch;	
?>
__________________
Need a vacation.
mb2000inc is offline
Reply With Quote
View Public Profile Visit mb2000inc's homepage!
 
Old 01-25-2011, 03:18 AM Re: New To PHP - Need help with conditional statements.
Average Talker

Posts: 15
Name: Kannan
Trades: 0
looking something like this?
Quote:
$dropdown = $_request['select_dropdown'];
if($dropdown == 1) $textbox = "something";
kannan is offline
Reply With Quote
View Public Profile Visit kannan's homepage!
 
Old 01-25-2011, 11:24 AM Re: New To PHP - Need help with conditional statements.
mb2000inc's Avatar
Extreme Talker

Posts: 150
Name: Mark
Location: Ohio
Trades: 0
hmm... I'm not sure that will do what I want, but I'll give it a shot.
Thanks,
__________________
Need a vacation.
mb2000inc is offline
Reply With Quote
View Public Profile Visit mb2000inc's homepage!
 
Old 01-25-2011, 04:09 PM Re: New To PHP - Need help with conditional statements.
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
You can't change the value of a textbox from a select element using PHP!
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 01-26-2011, 04:50 AM Re: New To PHP - Need help with conditional statements.
Average Talker

Posts: 15
Name: Kannan
Trades: 0
Quote:
Originally Posted by chrishirst View Post
You can't change the value of a textbox from a select element using PHP!
Yes, but by submitting the selected value with a page refresh could change the value of text box, right?
kannan is offline
Reply With Quote
View Public Profile Visit kannan's homepage!
 
Old 01-26-2011, 09:49 PM Re: New To PHP - Need help with conditional statements.
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
Quote:
Originally Posted by kannan View Post
Yes, but by submitting the selected value with a page refresh could change the value of text box, right?
Yes you can - You can get the form post value from the $_POST superglobal array and write the value in another var or overwrite the previous post value. Just output the new value in the html portion.

PHP Code:
<?php
  
  
if ($_POST['ddm_value'] == 1$_POST['txt_value'] = 'something';
  
?>
  
<textarea name="txt_value"><?php echo htmlentities($_POST['txt_value']); ?></textarea>
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to New To PHP - Need help with conditional statements.
 

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