notuserfriendly
Programmer
Hi I've got a form that is supposed to show an extra column field if the users makes the a certain choise, this is done by
This however doesn't go to well with me loading the page.
I use PHP and get the data from an database.
When accessing the page the field
always shows in the beginning. I'm wondering how to be able to set focus to a field when it's checked.
Tried many things but none of them worked, probably because this is kind of new for me.
Code:
if(strcmp($rowP["v$i"],"1") == 0 ){
$on = "checked ";
}
echo "\t\t<td><input type=\"radio\" name=\"v[$i]\" $on onfocus=\"this.checked;hideReason('v[$i]');return false;\" value=\"on\"></td>\n";
if(strcmp($rowP["v$i"],"-1") == 0 ){
$of = " checked ";
}
echo "\t\t<td><input type=\"radio\" name=\"v[$i]\" $of onfocus=\"this.checked;showReason('v[$i]');return true;\" value=\"off\"></td>\n";
if(strcmp($rowP["v$i"],"0") == 0 ){
$el = " checked ";
}
echo "\t\t<td><input type=\"radio\" name=\"v[$i]\" $el onfocus=\"this.checked;hideReason('v[$i]');return false;\" value=\"else\"></td>\n";
echo "<td id=\"v[$i]\"><INPUT value=\"reason\" name=\"vr[$i]\" size=\"7\"/></td>\n"
This however doesn't go to well with me loading the page.
I use PHP and get the data from an database.
When accessing the page the field
Code:
echo "<td id=\"v[$i]\"><INPUT value=\"reason\" name=\"vr[$i]\" size=\"7\"/></td>\n"
Tried many things but none of them worked, probably because this is kind of new for me.
Code:
function showReason(theTable)
{
obj = document.getElementsByTagName('td');
for (i=0; i<obj.length; i++)
{
if (obj[i].id == theTable)
obj[i].style.display = 'block';
}
}
function hideReason(theTable)
{
obj = document.getElementsByTagName('td');
for (i=0; i<obj.length; i++)
{
if (obj[i].id == theTable)
obj[i].style.display = 'none';
}
}