Board index   FAQ   Search  
Register  Login
Board index PHP Your Scripts

Where is the problem?

This is where you share YOUR scripts with others

Moderators: macek, egami, gesf

Where is the problem?

Postby omidpand » Sun Dec 04, 2011 11:27 pm

This code does not run in line 7, why?
Code: Select all
function selectcity()
        $('').val('<?php echo($_city); ?>');
        $('select.c0').val('<?php echo($_data_ar[0]); ?>');
        $('select.c1').val('<?php echo($_data_ar[1]); ?>');

        $('select.c2').val('<?php echo($_data_ar[2]); ?>');

        $('select.c3').val('<?php echo($_data_ar[3]); ?>');

The first combobox (C0) item selected and second combobox (C1) filled too, but nothing in second combobox did not select and so the third (C2) and the forth (C3) combobox did not fill.

The function change fill each combo box from what selected in previous combobx:
Code: Select all
function change(currentbox) {
   numb ="_");
   currentbox = numb[1];


// I empty all combo boxes following the current one

    while ((eval("typeof(document.getElementById(\"combo_"+i+"\"))!='undefined'")) &&
           (document.getElementById("combo_"+i)!=null)) {
         son = document.getElementById("combo_"+i);
        // I empty all options except the first one (it isn't allowed)
        for (m=son.options.length-1;m>0;m--) son.options[m]=null;
        // I reset the first option
        son.options[0]=new Option(displaywhenempty,valuewhenempty)

// now I create the string with the "base" name ("stringa"), ie. "data_1_0"
// to which I'll add _0,_1,_2,_3 etc to obtain the name of the combo box to fill

    while ((eval("typeof(document.getElementById(\"combo_"+i+"\"))!='undefined'")) &&
           (document.getElementById("combo_"+i)!=null)) {
           if (i==currentbox) break;

// filling the "son" combo (if exists)


    if ((eval("typeof(document.getElementById(\"combo_"+following+"\"))!='undefined'")) &&
       (document.getElementById("combo_"+following)!=null)) {
       son = document.getElementById("combo_"+following);
       while ((eval("typeof("+stringa+i+")!='undefined'")) || (i==0)) {

       // if there are no options, I empty the first option of the "son" combo
      // otherwise I put "-select-" in it

           if ((i==0) && eval("typeof("+stringa+"0)=='undefined'"))
               if (eval("typeof("+stringa+"1)=='undefined'"))
                  eval("son.options[0]=new Option(displaywhenempty,valuewhenempty)")
                eval("son.options[0]=new Option(displaywhennotempty,valuewhennotempty)")
              eval("son.options["+i+"]=new Option("+stringa+i+".text,"+stringa+i+".value)")
       while (cstatus[i]!=null) {
       return combostatus;
New php-forum User
New php-forum User
Posts: 3
Joined: Mon Nov 28, 2011 2:01 am

Re: Where is the problem?

Postby FollowTheTortoise » Mon Dec 12, 2011 7:49 am

Are you referring to the PHP on line 7 not being parsed correctly?
Or are you referring to the Javascript on line 7 not being executed correctly?

You are aware this is a php forum...
Heres a tutorial on debugging javascript which is what it sounds like you need.... ... beginners/
New php-forum User
New php-forum User
Posts: 82
Joined: Sun Dec 04, 2011 1:35 pm
Location: Southern California

Return to Your Scripts

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.