Current location: Hot Scripts Forums » General Web Coding » JavaScript » Form not updateding when I click radio button.


Form not updateding when I click radio button.

Reply
  #1 (permalink)  
Old 03-16-06, 09:25 PM
Spreegem Spreegem is offline
Newbie Coder
 
Join Date: Jan 2004
Location: In front of my computer
Posts: 95
Thanks: 0
Thanked 0 Times in 0 Posts
Form not updateding when I click radio button.

I'm trying to change some text in a form when I click a radio button, but it isnt working, I know the javascript is wrong, because this is the first tiem I have tried implementing it, but I just cant find what is wrong with it. Here is the javascript function
Code:
<script language="javascript">
function change_class(change_class, state)
	{
	//Change Class
	if (state)
		{
		var new_class = change_class;
		}
	
	//Set to None
	else
		{
		var new_class = "None";
		}

	document.forms[0].s_class.value=new_class;
	}

</script>

Here is the form I am trying to update
Code:
<p>Ship Class: <input name="s_class" type="text" id="s_class" value="Class"></p>

and here is the radio button thing
PHP Code:

<td width="20%"><input name="hull" type="radio" value="1" onclick="javascript:change_class(<? echo "$class1"?>, this.check)"></td>
I probably either did something wrong with the function, or I cant echo a PHP variable into the onclick, like you can echo variables into HTML Thanks in advance for any help, because this has been bugging me all day.
Reply With Quote
  #2 (permalink)  
Old 03-17-06, 08:14 AM
TwoD TwoD is offline
Community VIP
 
Join Date: Sep 2003
Location: 404
Posts: 1,813
Thanks: 0
Thanked 0 Times in 0 Posts
You should check for this.checked instead of this.check.
Btw, here's a quick way to do the if-else statement with variable assignment:
Code:
var new_class = state ? change_class : "None";
The syntax is simply:
variable = expression ? set_if_true : set_if_false;
This syntax can also be nested like if - else if - else statements if needed.

Echoing into JavaScript should be no problems, as long as you add quotation marks to make JS interpret it as a string.
__________________
[W3Schools - learn all about the standards.] [QuirksMode - Browser Quirks] [MS's Online Reference Docs] [DOM in Gecko.]
Please pay attention to stickys, announcements and forum rules, thank you.
Please also remember Code Wrappers and [SOLVED] Marking, this helps everyone.
Reply With Quote
  #3 (permalink)  
Old 03-21-06, 08:13 PM
Spreegem Spreegem is offline
Newbie Coder
 
Join Date: Jan 2004
Location: In front of my computer
Posts: 95
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks for that, sorry I didnt reply sooner, but I've been playing with it trying to make it work, but I just cant get it to work at all, so here is the code of the entire page, incase maybe the order of things are screwed up, or I have something named wrong Im not realizing.

PHP Code:

<?

include '../includes/header.php';
?>
<html>
<head>
<title>Space Baron :: Create a ship part 1 of 4 : Hull Selection</title>
<? include '../includes/meta_css.htm'?>

<script language="javascript">
function change_class(change_class, state)
    {
    //Change class
    var new_class = state ? change_class : "None";

    document.forms[0].s_class.value=new_class;
    }

</script>
</head>


<table width="100%" height="100%">
  <tr>  
    <td colspan="3"><img src="<? include '../includes/banner.php'?>" width="780" height="120" alt="Space Baron Banner" align="left"></td>
  </tr>
  
  <tr>
    <td width="160" height="100%" valign="top" background="../images2/stars2.gif">
    <? include '../includes/left.php'?>
    </td>
    
    <td width="1" height="100%"></td>
    
    <td height="100%" valign="top" background="../images2/stars2.gif">
    <?
    
if($error != '0')
        {
        echo 
"<p>$error</p><br>";
        }
    
    else
        {
        
$name $_SESSION['s_name'];
        
//Functions
        
include "../includes/ship_func.php";
        
        
//Class
        
$class1 class_s ($class1);
        
$class2 class_s ($class2);
        
$class3 class_s ($class3);
        
$class4 class_s ($class4);
        
$class5 class_s ($class5);
        
$class6 class_s ($class6);
        
$class7 class_s ($class7);
        
$class8 class_s ($class8);
        
        
//Armor
        
$armor1 h_armor ($class1$armor1);
        
$armor2 h_armor ($class2$armor2);
        
$armor3 h_armor ($class3$armor3);
        
$armor4 h_armor ($class4$armor4);
        
$armor5 h_armor ($class5$armor5);
        
$armor6 h_armor ($class6$armor6);
        
$armor7 h_armor ($class7$armor7);
        
$armor8 h_armor ($class8$armor8);
        
        
//Weight
        
$weight1 weight ($class1$weight1);
        
$weight2 weight ($class2$weight2);
        
$weight3 weight ($class3$weight3);
        
$weight4 weight ($class4$weight4);
        
$weight5 weight ($class5$weight5);
        
$weight6 weight ($class6$weight6);
        
$weight7 weight ($class7$weight7);
        
$weight8 weight ($class8$weight8);
        
        
//Cost
        
$cost1 s_cost ($weight1$armor1$cost1);
        
$cost2 s_cost ($weight2$armor2$cost2);
        
$cost3 s_cost ($weight3$armor3$cost3);
        
$cost4 s_cost ($weight4$armor4$cost4);
        
$cost5 s_cost ($weight5$armor5$cost5);
        
$cost6 s_cost ($weight6$armor6$cost6);
        
$cost7 s_cost ($weight7$armor7$cost7);
        
$cost8 s_cost ($weight8$armor8$cost8);
        
?>
        <form name="hull" method="post" action="engine.php">
        <table width="100%" border="0" cellpadding="0" cellspacing="0">
          <tr>
            <td align="left" valign="top" width="200">
            <center><p><b>Ship Overview</b></p></center>
            <p>Ship Class: <input name="s_class" type="text" id="s_class" value="Class"></p>
            <p>Armor: <input name="s_armor" type="text" id="s_armor" value="0"></p>
            <p>Armor Type: <input name="armor_type" type="text" id="armor_type" value="None"></p>
            <p>Engine Distance: <input name="eng_dis" type="text" id="eng_dis" value="0"></p>
            <p>Engine Speed: <input name="eng_speed" type="text" id="eng_speed" value="0"></p><br>
            
            <p>Total Weight: <input name="total_weight" type="text" id="total_weight" value="0"></p>
            <p>Current Weight: <input name="cur_weight" type="text" id="cur_weight" value="0"></p>
            <p>Weight Left: <input name="weight_left" type="text" id="weight_left" value="0"></p><br>
            
            <p>Total Money: <? echo "$on_hand"?></p>
            <p>Curent Cost: <input name="cur_cost" type="text" id="cur_cost" value="0"></p>
            <p>Money Left: <input name="money_left" type="text" id="money_left" value="0"></p>
            </td>
            
            <td align="left" valign="top" width="">
            <p class="indent">Ship creation part 1 of 4. Select a ship name, hull, and armor type.</p><br>
            
              <table width="100%" border="0" cellpadding="0" cellspacing="0">
                <tr> 
                  <td align="left"><p>Ship Name: <input name="s_name" type="text" id="s_name" value="<? echo $name?>"></p></td>
                </tr>
              </table>
              
              <br>
              <table width="100%" cellpadding="2" cellspacing="2">
                <tr>
                  <td width="" colspan="5"><center><p><b>Hulls</b></p></center></td>
                </tr>
                
                <tr>
                  <td width="20%"><p><u>Class</u></p></td>
                  <td width="20%"><p><u>Weight</u></p></td>
                  <td width="20%"><p><u>Armor</u></p></td>
                  <td width="20%"><p><u>Cost</u></p></td>
                  <td width="20%"><p><u>Select</u></p></td>
                </tr>
            
                <tr>
                  <td width="20%"><p><? echo $class1?></p></td>
                  <td width="20%"><p><? echo $weight1?></p></td>
                  <td width="20%"><p><? echo $armor1?></p></td>
                  <td width="20%"><p><? echo $cost1?></p></td>
                  <td width="20%"><input name="hull" type="radio" value="1" onclick="javascript:change_class(<? echo "$class1"?>, this.checked)"></td>
                </tr>
                <br>
                <tr>
                  <td width="20%"><p><? echo $class2?></p></td>
                  <td width="20%"><p><? echo $weight2?></p></td>
                  <td width="20%"><p><? echo $armor2?></p></td>
                  <td width="20%"><p><? echo $cost2?></p></td>
                  <td width="20%"><input name="hull" type="radio" value="2" onclick="javascript:change_class(<? echo "$class2"?>, this.checked)"></td>
                </tr>
            
                <tr>                                           
                  <td width="20%"><p><? echo $class3?></p></td>
                  <td width="20%"><p><? echo $weight3?></p></td>
                  <td width="20%"><p><? echo $armor3?></p></td>
                  <td width="20%"><p><? echo $cost3?></p></td>
                  <td width="20%"><input name="hull" type="radio" value="3" onclick="javascript:change_class(<? echo "$class3"?>, this.checked)"></td>
                </tr>
            
                <tr>
                  <td width="20%"><p><? echo $class4?></p></td>
                  <td width="20%"><p><? echo $weight4?></p></td>
                  <td width="20%"><p><? echo $armor4?></p></td>
                  <td width="20%"><p><? echo $cost4?></p></td>
                  <td width="20%"><input name="hull" type="radio" value="4" onclick="javascript:change_class(<? echo "$class4"?>, this.checked)"></td>
                </tr>
            
                <tr>
                  <td width="20%"><p><? echo $class5?></p></td>
                  <td width="20%"><p><? echo $weight5?></p></td>
                  <td width="20%"><p><? echo $armor5?></p></td>
                  <td width="20%"><p><? echo $cost5?></p></td>
                  <td width="20%"><input name="hull" type="radio" value="5" onclick="javascript:change_class(<? echo "$class5"?>, this.checked)"></td>
                </tr>
            
                <tr>
                  <td width="20%"><p><? echo $class6?></p></td>
                  <td width="20%"><p><? echo $weight6?></p></td>
                  <td width="20%"><p><? echo $armor6?></p></td>
                  <td width="20%"><p><? echo $cost6?></p></td>
                  <td width="20%"><input name="hull" type="radio" value="6" onclick="javascript:change_class(<? echo "$class6"?>, this.checked)"></td>
                </tr>
            
                <tr>
                  <td width="20%"><p><? echo $class7?></p></td>
                  <td width="20%"><p><? echo $weight7?></p></td>
                  <td width="20%"><p><? echo $armor7?></p></td>
                  <td width="20%"><p><? echo $cost7?></p></td>
                  <td width="20%"><input name="hull" type="radio" value="7" onclick="javascript:change_class(<? echo "$class7"?>, this.check)"></td>
                </tr>
            
                <tr>
                  <td width="20%"><p><? echo $class8?></p></td>
                  <td width="20%"><p><? echo $weight8?></p></td>
                  <td width="20%"><p><? echo $armor8?></p></td>
                  <td width="20%"><p><? echo $cost8?></p></td>
                  <td width="20%"><input name="hull" type="radio" value="8" onclick="javascript:change_class(<? echo "$class8"?>, this.checked)"></td>
                </tr>
              </table>
              
              <? 
              
//So this is where all of the armor types are displayed
              
?>
              <br>
              <table width="100%" cellpadding="2" cellspacing="2">
                <tr>
                  <td colspan="6"><center><p><b>Armor Types</b></p></center></td>
                </tr>
                
                <tr>
                  <td width="16%"><p><u>Type</u></p></td>
                  <td width="16%"><p><u>Cost Per Armor</u></p></td>
                  <td width="16%"><p><u>Weight Per Armor</u></p></td>
                  <td width=""><p><u>Armor Addition per 50 armor</u></p></td>
                  <td width="16%"><p><u>Damage Reduction %</u></p></td>
                  <td width="16%"><p><u>Select</u></p></td>
                </tr>
            
                <?
                
//Do a query to select all armor types
                
$query "SELECT * FROM armor_types";
                
$armor_types2 mysql_query($query);
                
                
//If there is an error, display an error message
                
if(!$armor_types2)
                    {
                    
?>
                    <p><? print '$query: '.$query.mysql_error();?></p>
                    <?
                    
}
                  
                
//If there are no armor types, this page is ****ed, tell them
                
elseif (!mysql_num_rows($armor_types2))
                    {
                    
?>
                    <p>There are no armor types, which means an error has occured, contact me through the contact form on the left.</p><br>
                    <?
                    
}
                
                else
                    {
                    
//Get the info, then display the info for all of the armor types
                    
while($armor_types mysql_fetch_array($armor_types2))
                        {
                        
$type $armor_types['name'];
                        
$cost_per_armor $armor_types['cost_per_armor'];
                        
$weight_per_armor $armor_types['weight_per_armor'];
                        
$defence_addition $armor_types['defence_addition'];
                        
$damage_reduction $armor_types['damage_reduction'];
                        
$armor_id $armor_types['armor_id'];
                        
                        
?>
                        <tr>
                          <td width="" valign="top"><p><? echo $type?></p></td>  
                          <td width="" valign="top"><p><? echo $cost_per_armor?></p></td>
                          <td width="" valign="top"><p><? echo $weight_per_armor?></p></td>
                          <td width="" valign="top"><p><? echo $defence_addition?></p></td>
                          <td width="" valign="top"><p><? echo $damage_reduction?></p></td>
                          <td width="" valign="top"><input name="armor_type" type="radio" value="<? echo "$armor_id"?>"></td>                        
                        </tr>
                        <?    
                        
}
                    }
                
?>
                <tr>  
                  <td colspan="4"><input type="submit" name="Submit" value="Continue to part 2 of 4"></td>
                </tr>
              </table>
            </td>
          </tr>
        </table>
        </form>
              
              <?
                $_SESSION
['h_class1'] = $class1;
                
$_SESSION['h_class2'] = $class2;
                
$_SESSION['h_class3'] = $class3;
                
$_SESSION['h_class4'] = $class4;
                
$_SESSION['h_class5'] = $class5;
                
$_SESSION['h_class6'] = $class6;
                
$_SESSION['h_class7'] = $class7;
                
$_SESSION['h_class8'] = $class8;
        
                
$_SESSION['h_weight1'] = $weight1;
                
$_SESSION['h_weight2'] = $weight2;
                
$_SESSION['h_weight3'] = $weight3;
                
$_SESSION['h_weight4'] = $weight4;
                
$_SESSION['h_weight5'] = $weight5;
                
$_SESSION['h_weight6'] = $weight6;
                
$_SESSION['h_weight7'] = $weight7;
                
$_SESSION['h_weight8'] = $weight8;
        
                
$_SESSION['h_armor1'] = $armor1;
                
$_SESSION['h_armor2'] = $armor2;
                
$_SESSION['h_armor3'] = $armor3;
                
$_SESSION['h_armor4'] = $armor4;
                
$_SESSION['h_armor5'] = $armor5;
                
$_SESSION['h_armor6'] = $armor6;
                
$_SESSION['h_armor7'] = $armor7;
                
$_SESSION['h_armor8'] = $armor8;


                
$_SESSION['h_cost1'] = $cost1;
                
$_SESSION['h_cost2'] = $cost2;
                
$_SESSION['h_cost3'] = $cost3;
                
$_SESSION['h_cost4'] = $cost4;
                
$_SESSION['h_cost5'] = $cost5;
                
$_SESSION['h_cost6'] = $cost6;
                
$_SESSION['h_cost7'] = $cost7;
                
$_SESSION['h_cost8'] = $cost8;
            }
    include 
'../includes/banner_ad.php';
    
?>
    </td>
    
    <td width="1" height="100%" ></td>
    
    <td width="160" height="100%" valign="top" background="../images2/stars2.gif">
    <center>
    <? include '../includes/tower.php'?>
    </center>
    </td>
    
  </tr>
</table>
<? include '../includes/footer.php'?>
</html>
Reply With Quote
  #4 (permalink)  
Old 03-21-06, 08:56 PM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,515
Thanks: 20
Thanked 109 Times in 106 Posts
Check out the arrays section at http://php.net/manual/en
Reply With Quote
  #5 (permalink)  
Old 03-22-06, 11:31 AM
Spreegem Spreegem is offline
Newbie Coder
 
Join Date: Jan 2004
Location: In front of my computer
Posts: 95
Thanks: 0
Thanked 0 Times in 0 Posts
How will arrays help me with my javascript problem? I know that I should be using arrays for all of the repeditive variables I generate with PHP. I just havent got around to it yet, but I'm trying to find out what's wrong with the javascript stuff.
Reply With Quote
  #6 (permalink)  
Old 03-22-06, 12:46 PM
TwoD TwoD is offline
Community VIP
 
Join Date: Sep 2003
Location: 404
Posts: 1,813
Thanks: 0
Thanked 0 Times in 0 Posts
It seems that the JavaScript is ok. But you're still checking for .check in atleast one place.
Could you post the source after it has been sent to the browser? That would help me determine if the PHP output is correct.
__________________
[W3Schools - learn all about the standards.] [QuirksMode - Browser Quirks] [MS's Online Reference Docs] [DOM in Gecko.]
Please pay attention to stickys, announcements and forum rules, thank you.
Please also remember Code Wrappers and [SOLVED] Marking, this helps everyone.
Reply With Quote
  #7 (permalink)  
Old 03-22-06, 03:46 PM
Spreegem Spreegem is offline
Newbie Coder
 
Join Date: Jan 2004
Location: In front of my computer
Posts: 95
Thanks: 0
Thanked 0 Times in 0 Posts
Ok, here's the source when Im in my browser

PHP Code:

<html>

<
head>
<
title>Space Baron :: Create a ship part 1 of 4 Hull Selection</title>
<
link rel="stylesheet" type="text/css" href="http://egames.servegame.com/space_game_1/includes/style.css" />
<
style type="text/css">
P.BIG
    
{
    
font-family:Tahoma;
    
font-size:14px;
    
margin-top:0;
    
margin-bottom:0;
    }
    
P.ERROR
    
{
    
font-family:Tahoma;
    
font-size:14px;
    
color:#FF0000;
    
margin-top:0;
    
margin-bottom:0;
    }
    
P.STRIKE
    
{
    
font-family:Tahoma;
    
font-size:12px;
    
color:#FFFFFF;
    
margin-top:0;
    
margin-bottom:0;
    
text-decoration:line-through;
    }
</
style>
<
script language="javascript">
function 
change_class(change_classstate)
    {
    
//Change class
    
var new_class state change_class "None";

    
document.forms[0].s_class.value=new_class;
    }

</script>
</head>


<table width="100%" height="100%">
  <tr>  
    <td colspan="3"><img src="http://egames.servegame.com/space_game_1/images2/banner2.jpg" width="780" height="120" alt="Space Baron Banner" align="left"></td>
  </tr>
  
  <tr>
    <td width="160" height="100%" valign="top" background="../images2/stars2.gif">
    <p><a href="http://egames.servegame.com/space_game_1/index.php">Home</a></p>

<p><a href="http://egames.servegame.com/space_game_1/forum/index.php">Forum</a></p>

<p><a href="http://egames.servegame.com/space_game_1/main/in_dev.php">In Development</a></p><p><a href="http://egames.servegame.com/space_game_1/user/comm_center.php">Command Center</a></p>

<p><a href="http://egames.servegame.com/space_game_1/ship/ship.php">Ship Maintenance</a></p>

<p><a href="http://egames.servegame.com/space_game_1/ship/cship_form.php">Ship Creation</a></p>

<p><a href="http://egames.servegame.com/space_game_1/traveling/system_view.php">System Navigation</a></p>

<p><a href="http://egames.servegame.com/space_game_1/combat/combat.php">Combat</a></p>

<p><a href="http://egames.servegame.com/space_game_1/trading/sell_form.php">Sell Items</a></p>

<p><a href="http://egames.servegame.com/space_game_1/trading/purchase_form.php">Purchase Items</a></p>

<p><a href="http://egames.servegame.com/space_game_1/trading/bank.php">Bank</a></p>

<p><a href="http://egames.servegame.com/space_game_1/pms/inbox.php">Private Messages</a></p>

<p><a href="http://egames.servegame.com/space_game_1/register/logout.php">Logout</a></p>            
    <br>
    <p>On Hand: $36150.38</p>
    <p>In Bank: $99900.00</p>

    <br>
        
            <p>
        Ship: USS Defiant I <br>Currently In: Sol <br>Fuel: / <br>        </p>
            <br>
    <br>
    <center>
        <script language='JavaScript' type='text/javascript' src='http://egames.servegame.com/space_game_1/an1/adx.js'></script>

    <script language='JavaScript' type='text/javascript'>
    <!--
       if (!document.phpAds_used) document.phpAds_used = ',';
       phpAds_random = new String (Math.random()); phpAds_random = phpAds_random.substring(2,11);
       
       document.write ("<" + "script language='JavaScript' type='text/javascript' src='");
       document.write ("http://egames.servegame.com/space_game_1/an1/adjs.php?n=" + phpAds_random);
       document.write ("&amp;what=zone:5");
       document.write ("&amp;exclude=" + document.phpAds_used);
       if (document.referrer)
          document.write ("&amp;referer=" + escape(document.referrer));
       document.write ("'><" + "/script>");
    //-->
    </script><noscript><a href='http://egames.servegame.com/space_game_1/an1/adclick.php?n=a15e7573' target='_blank'><img src='http://egames.servegame.com/space_game_1/an1/adview.php?what=zone:5&amp;n=a15e7573' border='0' alt=''></a></noscript>    
    </center>
        </td>
    
    <td width="1" height="100%"></td>
    
    <td height="100%" valign="top" background="../images2/stars2.gif">
            <form name="hull" method="post" action="engine.php">
        <table width="100%" border="0" cellpadding="0" cellspacing="0">
          <tr>
            <td align="left" valign="top" width="200">

            <center><p><b>Ship Overview</b></p></center>
            <p>Ship Class: <input name="s_class" type="text" id="s_class" value="Class"></p>
            <p>Armor: <input name="s_armor" type="text" id="s_armor" value="0"></p>
            <p>Armor Type: <input name="armor_type" type="text" id="armor_type" value="None"></p>
            <p>Engine Distance: <input name="eng_dis" type="text" id="eng_dis" value="0"></p>
            <p>Engine Speed: <input name="eng_speed" type="text" id="eng_speed" value="0"></p><br>

            
            <p>Total Weight: <input name="total_weight" type="text" id="total_weight" value="0"></p>
            <p>Current Weight: <input name="cur_weight" type="text" id="cur_weight" value="0"></p>
            <p>Weight Left: <input name="weight_left" type="text" id="weight_left" value="0"></p><br>
            
            <p>Total Money: 36150.38</p>
            <p>Curent Cost: <input name="cur_cost" type="text" id="cur_cost" value="0"></p>
            <p>Money Left: <input name="money_left" type="text" id="money_left" value="0"></p>

            </td>
            
            <td align="left" valign="top" width="">
            <p class="indent">Ship creation part 1 of 4. Select a ship name, hull, and armor type.</p><br>
            
              <table width="100%" border="0" cellpadding="0" cellspacing="0">
                <tr> 
                  <td align="left"><p>Ship Name: <input name="s_name" type="text" id="s_name" value=""></p></td>
                </tr>
              </table>

              
              <br>
              <table width="100%" cellpadding="2" cellspacing="2">
                <tr>
                  <td width="" colspan="5"><center><p><b>Hulls</b></p></center></td>
                </tr>
                
                <tr>
                  <td width="20%"><p><u>Class</u></p></td>
                  <td width="20%"><p><u>Weight</u></p></td>

                  <td width="20%"><p><u>Armor</u></p></td>
                  <td width="20%"><p><u>Cost</u></p></td>
                  <td width="20%"><p><u>Select</u></p></td>
                </tr>
            
                <tr>
                  <td width="20%"><p>Transport</p></td>
                  <td width="20%"><p>800</p></td>

                  <td width="20%"><p>700</p></td>
                  <td width="20%"><p>52500</p></td>
                  <td width="20%"><input name="hull" type="radio" value="1" onclick="javascript:change_class(Transport, this.checked)"></td>
                </tr>
                <br>
                <tr>
                  <td width="20%"><p>Scout</p></td>

                  <td width="20%"><p>300</p></td>
                  <td width="20%"><p>300</p></td>
                  <td width="20%"><p>21000</p></td>
                  <td width="20%"><input name="hull" type="radio" value="2" onclick="javascript:change_class(Scout, this.checked)"></td>
                </tr>
            
                <tr>                                           
                  <td width="20%"><p>Frigate</p></td>

                  <td width="20%"><p>900</p></td>
                  <td width="20%"><p>1000</p></td>
                  <td width="20%"><p>66500</p></td>
                  <td width="20%"><input name="hull" type="radio" value="3" onclick="javascript:change_class(Frigate, this.checked)"></td>
                </tr>
            
                <tr>
                  <td width="20%"><p>Scout</p></td>

                  <td width="20%"><p>200</p></td>
                  <td width="20%"><p>250</p></td>
                  <td width="20%"><p>15750</p></td>
                  <td width="20%"><input name="hull" type="radio" value="4" onclick="javascript:change_class(Scout, this.checked)"></td>
                </tr>
            
                <tr>
                  <td width="20%"><p>Scout</p></td>

                  <td width="20%"><p>200</p></td>
                  <td width="20%"><p>250</p></td>
                  <td width="20%"><p>15750</p></td>
                  <td width="20%"><input name="hull" type="radio" value="5" onclick="javascript:change_class(Scout, this.checked)"></td>
                </tr>
            
                <tr>
                  <td width="20%"><p>Frigate</p></td>

                  <td width="20%"><p>900</p></td>
                  <td width="20%"><p>900</p></td>
                  <td width="20%"><p>63000</p></td>
                  <td width="20%"><input name="hull" type="radio" value="6" onclick="javascript:change_class(Frigate, this.checked)"></td>
                </tr>
            
                <tr>
                  <td width="20%"><p>Scout</p></td>

                  <td width="20%"><p>250</p></td>
                  <td width="20%"><p>250</p></td>
                  <td width="20%"><p>17500</p></td>
                  <td width="20%"><input name="hull" type="radio" value="7" onclick="javascript:change_class(Scout, this.check)"></td>
                </tr>
            
                <tr>
                  <td width="20%"><p>Scout</p></td>

                  <td width="20%"><p>300</p></td>
                  <td width="20%"><p>300</p></td>
                  <td width="20%"><p>21000</p></td>
                  <td width="20%"><input name="hull" type="radio" value="8" onclick="javascript:change_class(Scout, this.checked)"></td>
                </tr>
              </table>
              
                            <br>

              <table width="100%" cellpadding="2" cellspacing="2">
                <tr>
                  <td colspan="6"><center><p><b>Armor Types</b></p></center></td>
                </tr>
                
                <tr>
                  <td width="16%"><p><u>Type</u></p></td>
                  <td width="16%"><p><u>Cost Per Armor</u></p></td>

                  <td width="16%"><p><u>Weight Per Armor</u></p></td>
                  <td width=""><p><u>Armor Addition per 50 armor</u></p></td>
                  <td width="16%"><p><u>Damage Reduction %</u></p></td>
                  <td width="16%"><p><u>Select</u></p></td>
                </tr>
            
                                        <tr>
                          <td width="" valign="top"><p>None</p></td>  
                          <td width="" valign="top"><p>0</p></td>

                          <td width="" valign="top"><p>0</p></td>
                          <td width="" valign="top"><p>0</p></td>
                          <td width="" valign="top"><p>0</p></td>
                          <td width="" valign="top"><input name="armor_type" type="radio" value="1"></td>                        
                        </tr>
                                                <tr>
                          <td width="" valign="top"><p>Aluminum</p></td>  
                          <td width="" valign="top"><p>2</p></td>

                          <td width="" valign="top"><p>3</p></td>
                          <td width="" valign="top"><p>5</p></td>
                          <td width="" valign="top"><p>2</p></td>
                          <td width="" valign="top"><input name="armor_type" type="radio" value="2"></td>                        
                        </tr>
                                                <tr>
                          <td width="" valign="top"><p>Steel</p></td>  
                          <td width="" valign="top"><p>6</p></td>

                          <td width="" valign="top"><p>10</p></td>
                          <td width="" valign="top"><p>10</p></td>
                          <td width="" valign="top"><p>5</p></td>
                          <td width="" valign="top"><input name="armor_type" type="radio" value="3"></td>                        
                        </tr>
                                                <tr>
                          <td width="" valign="top"><p>Titanium</p></td>  
                          <td width="" valign="top"><p>10</p></td>

                          <td width="" valign="top"><p>7</p></td>
                          <td width="" valign="top"><p>15</p></td>
                          <td width="" valign="top"><p>8</p></td>
                          <td width="" valign="top"><input name="armor_type" type="radio" value="4"></td>                        
                        </tr>
                                                <tr>
                          <td width="" valign="top"><p>Carbon Composite</p></td>  
                          <td width="" valign="top"><p>16</p></td>

                          <td width="" valign="top"><p>5</p></td>
                          <td width="" valign="top"><p>20</p></td>
                          <td width="" valign="top"><p>10</p></td>
                          <td width="" valign="top"><input name="armor_type" type="radio" value="5"></td>                        
                        </tr>
                                        <tr>  
                  <td colspan="4"><input type="submit" name="Submit" value="Continue to part 2 of 4"></td>
                </tr>

              </table>
            </td>
          </tr>
        </table>
        </form>
              
              <center><br><script type="text/javascript"><!--
google_ad_client = "pub-1553125570092253";
google_ad_width = 468;
google_ad_height = 65;
google_ad_format = "468x60_as";
google_ad_type = "text_image";
google_ad_channel = "3060835702";
google_color_border = "FFFFFF";
google_color_bg = "002640";
google_color_link = "FFFFFF";
google_color_url = "FF9900";
google_color_text = "FFFFFF";
//--></script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<br><br></center>    </td>

    
    <td width="1" height="100%" ></td>
    
    <td width="160" height="100%" valign="top" background="../images2/stars2.gif">
    <center>
    <script language='JavaScript' type='text/javascript' src='http://egames.servegame.com/space_game_1/an1/adx.js'></script>
<script language='JavaScript' type='text/javascript'>
<!--
   if (!document.phpAds_used) document.phpAds_used = ',';
   phpAds_random = new String (Math.random()); phpAds_random = phpAds_random.substring(2,11);
   
   document.write ("<" + "script language='JavaScript' type='text/javascript' src='");
   document.write ("http://egames.servegame.com/space_game_1/an1/adjs.php?n=" + phpAds_random);
   document.write ("&amp;what=zone:4");
   document.write ("&amp;exclude=" + document.phpAds_used);
   if (document.referrer)
      document.write ("&amp;referer=" + escape(document.referrer));
   document.write ("'><" + "/script>");
//-->
</script><noscript><a href='http://egames.servegame.com/space_game_1/an1/adclick.php?n=ae5af5e9' target='_blank'><img src='http://egames.servegame.com/space_game_1/an1/adview.php?what=zone:4&amp;n=ae5af5e9' border='0' alt=''></a></noscript>
    </center>
    </td>
    
  </tr>

</table>
</html> 
Reply With Quote
  #8 (permalink)  
Old 03-22-06, 06:17 PM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,515
Thanks: 20
Thanked 109 Times in 106 Posts
Arrays can be used to develop more efficient code. You are simulating an array with the $variable1 convention.

You're right - they may not be related to the Javascript problem - but they may help you write code that is easier to work with and maintain.
Reply With Quote
  #9 (permalink)  
Old 03-23-06, 01:23 AM
TwoD TwoD is offline
Community VIP
 
Join Date: Sep 2003
Location: 404
Posts: 1,813
Thanks: 0
Thanked 0 Times in 0 Posts
It's as I supspected.
The PHP script isn't echoing JavaScript strings, it's echoing variables.
Or atleast that's what the browser will think when encountering:
Code:
onclick="javascript:change_class(Scout, this.checked)"></
Here's how it should look:
Code:
onclick="javascript:change_class('Scout', this.checked)"
Fix that by doing:
Code:
onclick="javascript:change_class('<? echo "$class1"; ?>', this.checked)">
__________________
[W3Schools - learn all about the standards.] [QuirksMode - Browser Quirks] [MS's Online Reference Docs] [DOM in Gecko.]
Please pay attention to stickys, announcements and forum rules, thank you.
Please also remember Code Wrappers and [SOLVED] Marking, this helps everyone.
Reply With Quote
  #10 (permalink)  
Old 03-25-06, 06:50 PM
Spreegem Spreegem is offline
Newbie Coder
 
Join Date: Jan 2004
Location: In front of my computer
Posts: 95
Thanks: 0
Thanked 0 Times in 0 Posts
Ok, thanks a bunch I'll try it later when I get some free time. Thanks a bunch for helping me.
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
How to replace radio button in a form with a picture? amazing PHP 2 11-17-05 08:17 AM
Validating form radio boxes on submit (edit my code) Cepeleon JavaScript 2 04-08-05 04:08 AM
PHP Form - Button that executes - Need Help Proton PHP 1 02-05-05 10:27 PM
checkCheckboxGroup broken after form consolidation ski_woman JavaScript 0 01-12-05 11:00 AM
radio button selection TheLaughingBandit ASP 3 08-31-03 06:22 PM


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