Jump to content

jquery or javascript - script help


Destramic

Recommended Posts

im looking for a script which allows you to selected a certian option on a form select box then a row of list boxes will show underneath depending on what the select box value is....does anyone know of a good link to such a script/site/tutorial

 

if you dont understand let me know please...thank you

Link to comment
Share on other sites

im finnal on to something now...but the script im trying to function keeps returning an error on the json "failed to submit"...can anyone tell me why please

 

<!DOCTYPE html>
<html>
<head>
  <script type="text/javascript" src="/ajax/jquery/libary/jquery.js"></script>
</head>
<body>
<?php 
$game_type = array();
$division  = array();

if ($_POST['game'] == 1)
{
$game_type[] = array('value' => '1',
	                 'text' => 'TDM'
);

    $division[] = array('value' => '1',
	                 'text' => 'Divison 1'
);
}
elseif ($_POST['game'] == 2)
{
$game_type[] = array('value' => '1',
	                 'text' => 'CTF'
);

    $division[] = array('value' => '1',
	                 'text' => 'Divison 2'
);
}

json_encode($game_type);
json_encode($division);
?>
<form>
<script>	
$(document).ready(function(){
$("select#game").change(function(){

	$.ajax({
		type: 'POST',
        data: 'data',
        dataType: 'json',
        cache: false,
        url: 'json.php',
        timeout: '2000',
        error: function() {
        	alert("Failed to submit");
        },
        success: function(data) { 
        	alert("working!");
			 }
	});

        //	$('#game_type').html('<input type=\"checkbox\" value=\"test\" /> TDM'); 
        //   $('#division').html('<input type=\"checkbox\" value=\"test\" /> Division 1'); 

});
});

</script>
<select name="game" id="game">
<option value=""></option>
<option value="1">Counter Strike</option>
<option value="2">COD</option>
</select>

<div id="game_type">
</div>
<div id="division">
</div>
</form>

</body>
</html>

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.