0 Replies - 1626 Views - Last Post: 04 February 2009 - 01:45 AM Rate Topic: -----

#1 napsternapster   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 04-February 09

passing array content from a php file to javascript function and subtr

Posted 04 February 2009 - 01:45 AM

hi..
I have php file with a select dropdown when u select and item from the dropdown a textbox must show.On the onblur of the textbox the context of an array,selected,entered contact detail from the textbox must be sent to a javascript function called deleteFromList. The function must compare the list from the array with the selected items from the php dropdown and when a match is found that item wont be moved to the new list.the newlist must be returned to the php file populating the dropdown with its content


// php file with the onblur and onchange state
for($i = 2;$i <= 10; $i++)
{
$ct = $ct_id ;
$previous = 0;
//$ctid++;
$display_info .="<select onchange=\"showNext(this.value,'txt$ct_id"."_$i',' ','','$counter','$ct_id')\"
style =\"display:none\" id=\"select_id$ct_id"."_$i"."\" name=\"select_id$ct_id"."_$i"."\" >
<option value=\"0\">-- Select one --</option>";

//Populates the dropdown list from the $FullListDesc and the$FullListID
//array_push($FullListID,$FullListID);
for($d = 0;$d < $counter;$d++)
{
$display_info .= "<option value=\"$FullListID[$d]\">$FullListDesc[$d]</option><br>";

}
$display_info .=" </select>";

$next = $i + 1;
if($i > 1)
{
$previous = $next - 1;
}
$ctid++;
//the onblur function contains 4 parameters
if(($i >1 ) && ($i <= 9))
{


$display_info .= "&nbsp;<input type=\"text\" id=\"txt$ct_id"."_$i"."\"
name=\"txt$ct_id"."_$i"."\" style =\"display:none\"
onblur=\"deleteFromList(this.value,'$FullListID[$ctid]'),
showNext(this.value,'select_id$ct_id"."_$next','se lect_id$ct_id"."_$previous','txt$ct_id"."_$i')\"
size=15 maxlength=70>&nbsp;&nbsp;&nbsp;";
}
else
{
$display_info .="&nbsp;<input type=\"text\" id=\"txt$ct_id"."_$i"."\"
name=\"txt$ct_id"."_$i"."\" style =\"display:none\"
size=15 maxlength=70>";
}

if(($i == 4) || ($i == 7))
{
$display_info .= "<br>";
}
//echo $FullListID[$i]."<br>";
//echo $FullListID[$ctid];
}
//showing the following textbox or select dropdown
var selected = new Array();

function showNext(text,next,previous,current,count,ct_id)
{
var previous = document.getElementById(previous);
var next = document.getElementById(next);
var current = document.getElementById(current);

if((text.length > 1) &&(text.length >=9))
{
//alert(text);
next.style.display ='inline';
next.focus();
//alert(selected);
}
else if((text.length <= 2) && (text.length > 0))
{
/*if( "select_id"+ct_id+"_"+count == current)
{

}*/
selected.push(text);

next.style.display ='inline';
next.focus();
}

if((text.length != 2) )
{
if(text == "")
{
previous.style.display = 'none'
current.style.display = 'none'
next.focus();
}
}
}




var unSelected = new Array();

//deletes the selected contact type from a list of contact type
function deleteFromList(text,fullList)
{
var newList = new Array();

newList = fullList;

alert(newList);



var i = 1;
var found = "no";
var flag;

for(i =1; i <= 2 ;i++)
{
var j = 1;
for(j = 1;j <= 2; j++)
{
if(newList[j] == selected[j])
{
flag = found;

}
}
if(flag != found)
{
unSelected[i] = selected[i];
}
alert(selected);
}
alert(unSelected);
}
========================
can any one show me how to populate the drop down with new list and passing the content of array to Javascript function

Is This A Good Question/Topic? 0
  • +

Page 1 of 1