Jump to content

Hi


magi

Recommended Posts

Hey Everyone, sorry to bother you but im having some problems.

 

I am making a calculator for an online game to calculate attacks and things.

 

 

However i cannot seem to get his part here to work.

 

   

 echo'<td align"left" width="155">
<select class="inputBox" id="iRacePK0" name="D1">
<option value="1">Dwarven                                                                               </option><option value="2">Imperials                                                                                          </option><option value="3">Shinobi                                                                                            </option><option value="4">Templars                                                                                          </option><option value="5">Treefolk                                                                                           </option><option value="6">Avian                                                                                              </option><option value="7">Abominations                                                                                    </option><option value="8">Orcs                                                                                              </option><option value="9">Snowkin                                                                                         </option></select>
</td></tr><tr>';
  
if(D1=='Dwarven'){  
echo'<td align"left" width="155"> Gnome Sapper </td>'; 
}else if(D1==2){
echo'<td align"left" width="155"> Your Mom </td>';
}                 

  echo'<td align"left" width="155"><input type="hidden" name="unitpk1"><input type="hidden" name="totalunits1">';
                                              echo'<input type="text" name="totalunitssent1" class="inputbox" value="0" maxlength="9" size="6"></td></tr><tr>';

 

What i am trying to do is if the select drop down box is a certain race, to put the unit name  and then there is an input box. I also want it to change when a new race is selected but currently it only changes when my button is pressed. Any help ?

Link to comment
Share on other sites

NO, what i want to do is this

 

 

I have a select list with different items.

 

If i change the item to Dwarven

 

it comes out like this

 

Race: Dwarven

Unit 1: Gnome Sapper

 

then when i cange the race this appears

 

Race: Templar

Unit 1: Imperial

Link to comment
Share on other sites

i dont think that this will solve you prob coz the way i see it theres still more error any way try this and tell me the following error

 

echo'<td align"left" width="155">

<select class="inputBox" id="iRacePK0" name="D1">

<option value="1">Dwarven </option>

<option value="2">Imperials</option>

<option value="3">Shinobi</option>

<option value="4">Templars

</option><option value="5">Treefolk</option>

<option value="6">Avian </option>

<option value="7">Abominations </option>

<option value="8">Orcs</option>

<option value="9">Snowkin </option></select>

</td></tr><tr>';

 

if($_POST['D1']=='Dwarven')

echo'<td align"left" width="155"> Gnome Sapper </td>';

}else

{

echo'<td align"left" width="155"> Your Mom </td>';

}               

 

  echo'<td align"left" width="155"><input type="hidden" name="unitpk1"><input type="hidden" name="totalunits1">';

                                              echo'<input type="text" name="totalunitssent1" class="inputbox" value="0" maxlength="9" size="6"></td></tr><tr>';

 

 

first $_POST['D1'] you initialize in your code the ID it good if that was defined

 

then tell me the other thing obaut your code

Link to comment
Share on other sites

Well i feel stupid now that that was all it was :P

 

Now for the second part what i would like to do is when you change the selection in the box, it resets the page with the new data

 

For example

 

When you go to the page

 

Racw: Dwarven

Unit: Imps

 

When you change the race to Imperials, it refreshes the page and puts

 

Race: Imperials

Unit: G's

Link to comment
Share on other sites

That didnt seem to work, however i do have another question. I decided to try a different way to do this and it doesnt seem to be working. This way is much more efficient for me as i dont want to be doing 50 if statements. This was used on another page of mine and works fine but will not work on this page.

 

 

<select class="inputBox" id="iRacePK0" name="D1" onchange="javascript:document.getElementById("myForm").submit()"><option value="1">Dwarven                                                                               </option><option value="2">Imperials                                                                                          </option><option value="3">Shinobi                                                                                            </option><option value="4">Templars                                                                                          </option><option value="5">Treefolk                                                                                           </option><option value="6">Avian                                                                                              </option><option value="7">Abominations                                                                                    </option><option value="8">Orcs                                                                                              </option><option value="9">Snowkin                                                                                         </option></select>
</td></tr><tr>';
  
$get_min_id=mysql_query("SELECT MIN(id) FROM mnamedb WHERE race= '$_POST[D1]'",$link ) or die(mysql_error());	 
		$min_id=mysql_fetch_array($get_min_id);			
		$m_details=mysql_query("SELECT * FROM mnamedb WHERE race = '$_POST[D1]' AND atk!=0 ORDER BY id ASC",$link ) or die(mysql_error());	 
			while ($details=mysql_fetch_array($m_details)){
				$m=$details[id]-$min_id[0]+1;
				if ($m==1) $m_num=m1;
				if ($m==2) $m_num=m2;
				if ($m==3) $m_num=m3;
				if ($m==4) $m_num=m4;
				if ($m==5) $m_num=m5;
				if ($m==6) $m_num=m6;
				// only show if current have troops of that type
				if ($newarray[$m_num]!=0){
				echo'<tr class="admincell"><td><span onMouseover="ddrivetip(\'Offense:'.$details[3].'<br>Defense:'.$details[4].'<br>Mage:'.$details[6].'<br>Spy:'.$details[5].' \')" onMouseout="hideddrivetip()">'.$details[mname].'</span> </td>';
				echo"<td>".number_format($newarray[$m_num])." </td>"; // display current troops strength
				echo'<td><input class="inputp" name="'.$m_num.'" type="text" size="5" maxlength="5" value="'.$_POST[$m_num].'"></td></tr>'; // display textbox					
				}
			}

 

$get_min_id=mysql_query("SELECT MIN(id) FROM mnamedb WHERE race= '$_POST[D1]'",$link ) or die(mysql_error());	 
		$min_id=mysql_fetch_array($get_min_id);			
		$m_details=mysql_query("SELECT * FROM mnamedb WHERE race = '$_POST[D1]' AND atk!=0 ORDER BY id ASC",$link ) or die(mysql_error());	 
			while ($details=mysql_fetch_array($m_details)){
				$m=$details[id]-$min_id[0]+1;
				if ($m==1) $m_num=m1;
				if ($m==2) $m_num=m2;
				if ($m==3) $m_num=m3;
				if ($m==4) $m_num=m4;
				if ($m==5) $m_num=m5;
				if ($m==6) $m_num=m6;
				// only show if current have troops of that type
				if ($newarray[$m_num]!=0){
				echo'<tr class="admincell"><td><span onMouseover="ddrivetip(\'Offense:'.$details[3].'<br>Defense:'.$details[4].'<br>Mage:'.$details[6].'<br>Spy:'.$details[5].' \')" onMouseout="hideddrivetip()">'.$details[mname].'</span> </td>';
				echo"<td>".number_format($newarray[$m_num])." </td>"; // display current troops strength
				echo'<td><input class="inputp" name="'.$m_num.'" type="text" size="5" maxlength="5" value="'.$_POST[$m_num].'"></td></tr>'; // display textbox

 

This above code is the part that seems not to be working. Im not sure why it doesnt work though. It will display the text box in the wrong part of the code but the text box displays nonetheless, HOwever i cannot get any of the info from my query to appear with the text box, any help ?

Link to comment
Share on other sites

One of the reasons your getting little response is your lack of a decent subject title, and also a pretty distinct lack of being able to build a decent question. You might benifit from a read of the How to.... link in my signiture.

 

As for your issue. Could be a number of things but this stands out for me.

 

if ($m==1) $m_num=m1;

 

m1 meens nothing to PHP. Have you defined it as a constant somewhere? Otherwise, it needs to be dfined as a string...

 

if ($m==1) $m_num="m1";

 

I suggest you turn on error reporting and let us know what errors your getting.

Link to comment
Share on other sites

OK Sorry, i will try to be a bit more clear.

 

 

When you go to the page, a form appears with a selection box. In the selection box is different races.

 

It first appears like this

 

Race : (dropdown box with different races) Dwarven is the first one

 

Unit: (this is the dwarvens first unit) Gnome Sapper

 

What i want to happen is that when i change the dropdown box option the unit name will change according to what the race is.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.