Go Back   CodingForums.com > :: Client side development > JavaScript programming > Ajax and Design

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-04-2009, 01:10 AM   PM User | #1
noluckwithjava
New to the CF scene

 
Join Date: Apr 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
noluckwithjava is an unknown quantity at this point
Strange Javascript Messagebox Behavior

Hi all, I've trying to run a webpage with the following code:

Code:
<head>
	<import json.js>
	<script type="text/javascript">
		function keypressed() {
			var selectElement = $('id_community');
			var communityName = $('communityTextBox');
			var request = new Ajax.Request('../' + communityName.value + '/schoolList/',
			  {
			    method:'get',
			    onSuccess: function(transport){
			      var response = transport.responseText || "no response text";
				  var myObject = eval('('+ response +')')
				  for(var loop = selectElement.options.length; loop >= 0; loop--) {
					selectElement.options[loop] = null;
				  }
				  for(var i=0; i<=myObject.number; i++) {
					    var newElement = document.createElement('option');
					    newElement.text = myObject.colors[i];
					    newElement.value = myObject.values[i];
				            //alert(newElement.value);
					    selectElement.options.add(newElement);
				  }
			    },
			    onFailure: function(){ return }
			  });	
	    }
	
	</script>
and a form that looks like this:

Code:
<form action="." method="post" enctype="multipart/form-data">
  <table>
    <tr><th><label for="id_community">Community:</label></th><td></td><td>
	
		<input type="textarea" id="communityTextBox" onKeyUp="javascript:keypressed()" onFocus="if(this.value=='School Name...')this.value=''" value="School Name..." style="width:235px">
	</td></tr>
	
	<tr><td></td><td></td><td><select name="community" id="id_community" style="width:235px">

	</select><br /></td></tr>

<tr><th><label for="id_newUsername">Username:</label></th><td></td><td><input id="id_newUsername" type="text" name="newUsername" maxlength="30" style="width:235px"/></td></tr>
<tr><th><label for="id_email">Email:</label></th><td></td><td><input type="text" name="email" id="id_email" style="width:235px" /></td></tr>
<tr><th><label for="id_Password2">Password:</label></th><td></td><td><input id="id_Password2" type="password" name="Password2" maxlength="16" style="width:235px" /></td></tr>
<tr><th><label for="id_Password1">Password (Again):</label></th><td></td><td><input id="id_Password1" type="password" name="Password1" maxlength="16"  style="width:235px" /></td></tr>
  </table><br />
	<div id="tableSubmit">

	  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="submit" name="submit" value="Cancel" />

	  &nbsp;&nbsp;&nbsp;&nbsp;<input type="submit" name="submit" value="Continue"/>
	</div>
</form>

when i fill in the page and hit submit, the form refuses to properly submit and i get error messages telling me that none of the elements have been submitted.
HOWEVER, when i uncomment the line //alert(newElement.value); everything works as it should! Does anyone have any clue as to why this strange behavior is going on?
I've tried it both in google chrome and in firefox to the same end, and the firefox javascript error checker doesn't flash any errors or warnings or anything.

THanks a lot!!
-Robert
noluckwithjava is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT +1. The time now is 05:28 PM.


Advertisement
Log in to turn off these ads.