Current location: Hot Scripts Forums » Programming Languages » PHP » Problem with SWITCH function in Radio Button group


Problem with SWITCH function in Radio Button group

Reply
  #1 (permalink)  
Old 02-27-04, 10:03 AM
maverickblair maverickblair is offline
Newbie Coder
 
Join Date: Feb 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Question Problem with SWITCH function in Radio Button group

I have a radio group with two radio buttons (new & used). I also have a current_value that reads the records current value in the database. I want the correct radio button to be 'true' base on the current_value field

Here is my code that I current have. But it doesn't work:

PHP Code:
PHP Code:

<td> Current value of listing: 

<input name="current_value" type="text" class="formelements" id="current_value" value="<? print "$new_used"?>" disabled="true" size="10"> 
Edit listing to be 
<? 
// CHECKS TO SEE WHAT THE CURRENT VALUE IS AND POPULATES THE CORRECT RADIO BUTTON BELOW 
$value 'current_value'
switch (
$value === '' $value) { 
   case 
'new'
       echo 
$new true
       break; 
   case 
'used'
       echo 
$used true
       break; 

?> 
<input name="new_used" type="radio" class="formelements" id="new" value="new">new or 
<input name="new_used" type="radio" class="formelements" id="used" value="used">pre-owned 
</td>
thanks for any help
Reply With Quote
  #2 (permalink)  
Old 02-27-04, 10:49 AM
NeverMind's Avatar
NeverMind NeverMind is offline
Community VIP
 
Join Date: Aug 2003
Location: K.S.A
Posts: 2,257
Thanks: 0
Thanked 2 Times in 1 Post
this is a wrong way to use Switch !!
first of all you are giving the value to $value which is 'current_value' so all the switch statment is usless ,,
you may use it like this :
PHP Code:

switch ($value) {

  case 
'new':
    
$new true;
    break;
 case 
'used':
    
$used true;
    break;
 case 
false:
    
$value '';
    break;

__________________
PHPSimplicity
We don't need a reason to help people - Zidane [FF9]
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Trouble with SWITCH function in Radio Button group maverickblair PHP 0 02-25-04 08:13 AM
Problem in function? musicalmidget PHP 8 02-09-04 11:43 PM
accessing existing ISP email with a PHP webmail script. nlancaster PHP 1 01-07-04 03:28 AM
Help trim code down TheLaughingBandit JavaScript 0 09-02-03 09:50 AM
radio button selection TheLaughingBandit ASP 3 08-31-03 06:22 PM


All times are GMT -5. The time now is 09:05 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.