CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 PHP Ajax Function Not Working

Print topic Send  topic

Author Message
kinsesyete

Posts: 9
Posted: 01/28/2011, 11:25 PM

:(This is my Ajax Function for my select list Year Level to change what is in the database..

  
	 xmlhttp4.onreadystatechange=function()  
     {  
	 var lol1;  
	 var lol2;  
	 var fir;  
	 var sec;  
	 //document.form1.yearlvl.selectedIndex = 3;  
       if(xmlhttp4.readyState==4 && xmlhttp4.status==200)  
       {  
	   sec = xmlhttp4.responseText;  
	   lol1 = sec.replace("\n", "");		  
		   switch(lol1)  
		   {  
				case "1st":  
					document.form1.yearlvl.selectedIndex = 1;  
					break;  
				case "2nd":  
					document.form1.yearlvl.selectedIndex = 2;  
					break;  
				case "3rd":  
					document.form1.yearlvl.selectedIndex = 3;  
					break;  
				case "4th":  
					document.form1.yearlvl.selectedIndex = 4;  
					break;  
		   }  
       }  
     }   

And This is my Select List in HTML

  
<select name = yearlvl id = yearlvl>  
	<option>Choose Year Level</option>  
  	<option value = "1st">1st Year</option>  
       <option value = "2nd">2nd Year</option>  
       <option value = "3rd">3rd Year</option>  
	<option value = "4th">4th Year</option>  
</select>  

I don't know why it doesn't seem to work T___T
Thanks for any help
-EM
View profile  Send private message
damian

Posts: 838
Posted: 01/29/2011, 1:24 AM

why do you need ajax for a listbox? is it part of a dependent listbox? is it updating db onchange? other?
_________________
if you found this post useful take the time to help someone else.... :)
View profile  Send private message
kinsesyete

Posts: 9
Posted: 01/29/2011, 1:35 AM

Quote damian:
why do you need ajax for a listbox? is it part of a dependent listbox? is it updating db onchange? other?

im using ajax so that the value i get from the database will be the the selected index in the text box

LOGIC:
if 1styear is found in the database,
1st year will be selected in the select list..

got me? ^^
View profile  Send private message
damian

Posts: 838
Posted: 01/29/2011, 1:57 AM

ccs will do that for you anyway without js...
_________________
if you found this post useful take the time to help someone else.... :)
View profile  Send private message
kinsesyete

Posts: 9
Posted: 01/29/2011, 3:43 AM

huh? What are you talking about? CSS? It's Client Side..
View profile  Send private message
damian

Posts: 838
Posted: 01/29/2011, 7:10 AM

Quote kinsesyete:
huh? What are you talking about? CSS? It's Client Side..
ccs = code charge studio
database is server side. if the form (eg update.php?id=54) sees data in the database for the record you are editing, it will display that data in the form fields - regardless of the type of control used in that field - textbox, listbox, checkbox, radiobutton etc.


_________________
if you found this post useful take the time to help someone else.... :)
View profile  Send private message
kinsesyete

Posts: 9
Posted: 01/29/2011, 7:44 AM

ahh i see..
I have no problem with sending the output in the textbox
except for the select list..
View profile  Send private message
damian

Posts: 838
Posted: 01/29/2011, 8:04 AM

build a quick test page... try it - maybe something broke on your current page. should take under 5mins to use builder to make grid and then modify one field to listbox and enter your list of values.

_________________
if you found this post useful take the time to help someone else.... :)
View profile  Send private message
kinsesyete

Posts: 9
Posted: 01/29/2011, 8:08 AM

I tried that..
but the problem is, the function doesn't trigger the loop..
i tried document.form1.yearlvl.selectedIndex = 1;
the select list changes, but when I apply a loop and an If else inside, it doesnt work..

:(
View profile  Send private message
damian

Posts: 838
Posted: 01/29/2011, 8:46 AM

ok, rollback, what function? what loop? why are you doing client side stuff? if you change that control back to textbox does it show the current data?

_________________
if you found this post useful take the time to help someone else.... :)
View profile  Send private message
kinsesyete

Posts: 9
Posted: 01/29/2011, 9:09 AM

Quote damian:
ok, rollback, what function? what loop? why are you doing client side stuff?
Check my Code ^


Quote damian:
if you change that control back to textbox does it show the current data?

yup, the data appears..even i do a messagebox
View profile  Send private message
damian

Posts: 838
Posted: 01/29/2011, 2:16 PM

Quote kinsesyete:
Quote damian:
ok, rollback, what function? what loop? why are you doing client side stuff?
Check my Code ^
im not going to try to understand your function. if your function is only retrieving datafrom db to set value on listbox in before show then its redundant. if your function does something else please say so.

Quote kinsesyete:
Quote damian:
if you change that control back to textbox does it show the current data?

yup, the data appears..even i do a messagebox
so if the data appears then right click and change to list box.

_________________
if you found this post useful take the time to help someone else.... :)
View profile  Send private message
damian

Posts: 838
Posted: 01/30/2011, 3:00 AM

im wondering if you are missing a config step of the listbox because its obviously not working for you. ill try to lay out the rest of the steps.

right click your textbox and change it to a listbox
left click the listbox.
on the properties -> data toolbox -> data source type -> change it to -> listofvalues
-> data source -> click the ... -> this will launch visual query builder
click on the + Add icon
enter 1st and 1st Year -> click ok
do the same for 2nd, 3rd, 4th
click on ok
publish and test.

it should work...



_________________
if you found this post useful take the time to help someone else.... :)
View profile  Send private message
kinsesyete

Posts: 9
Posted: 01/30/2011, 7:02 AM

I'm just using notepad for this.. :(
View profile  Send private message
damian

Posts: 838
Posted: 01/30/2011, 12:43 PM

so you are NOT using code charge studio?

_________________
if you found this post useful take the time to help someone else.... :)
View profile  Send private message
kinsesyete

Posts: 9
Posted: 01/30/2011, 9:40 PM

Quote damian:
so you are NOT using code charge studio?


yup, I never mentioned that..
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.