rbroder
Posts: 67
|
| Posted: 05/11/2011, 1:58 PM |
|
I need to have a list box whose drop-down content is dependent on the content of a text field in the same editable grid record.
Each record in the grid contains a reference to a record in another table (that record's Primary Key). The user does not know the primary key of the record in question but does know the value of one important field (the text field). After auto-completing the field, the listbox SQL should show a list of dates from records in the target table. That is, the listbox text would be dates and the values would be the primary key of the target record. Anyone know how? Please don't just say use Ajax: I'm not that smart. A reference to an existing example would be helpful.
rod
|
 |
 |
damian
Posts: 838
|
| Posted: 05/11/2011, 3:30 PM |
|
now that you ruled out the most likely technology to deliver this feature I dont think you will get too many responses...
_________________
if you found this post useful take the time to help someone else.... :)
|
 |
 |
andy
Posts: 183
|
| Posted: 05/11/2011, 4:30 PM |
|
The CodeCharge Tools dependant listbox works a treat - with or without AJAX.
Worth the small fee!
http://codechargetools.com/product.php?product_id=2
Set your autocomplete text box as parent and your listbox as dependant and you should be jiving...
I tried and gave up with the CCS dependant listboxes but CC Tools is very good.
_________________
Andy
RAD tools for rich UI controls:
http://www.koolphptools.com |
 |
 |
Waspman
Posts: 948
|
| Posted: 05/11/2011, 11:55 PM |
|
Do it with Ajax 
I can't be hard, I can do it!
_________________
http://www.waspmedia.co.uk |
 |
 |
rbroder
Posts: 67
|
| Posted: 05/12/2011, 6:53 AM |
|
Damian, Waspman: not trying to start a flame war, but responses like yours are what I didn't want. Both of you have helped out many users in the past. I just wanted some kind of prototype or pseudocode explanation. 
It appears to me that the built in AJAX dependent list box tools can only use a listbox as the master. I need the master to be a text field.
rod
|
 |
 |
datadoit
|
| Posted: 05/12/2011, 7:58 AM |
|
Well, AJAX would be the required method. I can't think of any way else.
You're also dealing with an editable grid, which has it's own layer of
complication for getting the row field's value via javascript.
Not exactly something where the 'solution' can be posted in a forum.
It'll be a fair bit of coding. I would suggest posting specs and
details to the jobs-available forum and let folks bid on a solution for you.
|
|
|
 |
Waspman
Posts: 948
|
| Posted: 05/12/2011, 8:01 AM |
|
What's a flame war?
Besides you said you didn't want to use Ajax, I was just saying it's the way I'd do it.
I'll have mess and get back to ya...
_________________
http://www.waspmedia.co.uk |
 |
 |
rbroder
Posts: 67
|
| Posted: 05/12/2011, 8:15 AM |
|
Waspman, a flame war is where I say something snarky to you, and you respond in kind, and that just escalates, and other people jump in the fray, we get off topic, and just disintegrate into a hating match. Not my intention.
I didn't say I didn't want to use AJAX. I just know how to use the built-in tools with CCS. Not ready to roll my own JavaScript/PHP from scratch.
rod
|
 |
 |
Waspman
Posts: 948
|
| Posted: 05/12/2011, 9:13 AM |
|
the post that someone made about integration of a php script works really well, this one...
<script type="text/javascript">
function getprice(str,optrow)
{
var xmlhttp;
if (str=="")
{
document.getElementById("optcost").innerHTML="";
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("optcost").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","option_cost.php?optionID="+str,true);
xmlhttp.send();
}
</script>
<script type="text/javascript">
function getprice(str,optrow)
{
var xmlhttp;
if (str==undefined)
{
document.getElementById("optcost"+optrow).innerHTML="";
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("optcost"+optrow).innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","option_cost.php?optionID="+str,true);
xmlhttp.send();
}
</script>
You can pass the row id quite easily sort of...
onchange="showCustomer(this.value,{form_components:rowNumber})"
I've done this on an editable grid so it does work.
This works with a dropdown really well.
So you need to figure out to trigger it using onkeyup like you do when checking password strength.
I'll keep looking...
_________________
http://www.waspmedia.co.uk |
 |
 |
|