|
|||||||
| JavaScript JavaScript (not Java) Discussion and technical support, including AJAX and frameworks (JQuery, MooTools, Prototype...) |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
hello friends i am having problem here.
when i click a check box i need to display data in a text box and one item should be selected in the combobox. i am using this script in php.. and ckman1.value is a string not a integer so how can i select a value in a combobox called man1.. here javascript for txtballname1 is working but for man1 itis not working... <script language="javascript"> function setball() { var Lform2 = this.document.advbbsearch2; var Lform1= this.document.advbbsearch1; Lform2.txtballname1.value = Lform1.ckb1.value; Lform2.man1.selectedindex = Lform1.ckman1.value; return true; } </script> ********************************************* echo "<input type=\"hidden\" value=\"".$ballname1."\" name=\"ckb1\""; echo "<input type=\"hidden\" value=\"".$manu1."\" name=\"ckman1\""; ********************************************* echo "<input type=\"checkbox\" name=\"chkbox1\" value=\"ball1\" onclick=\" return setball()\" align=\"right\">"; so please help me ....... Jaydeep Vadher.... |
|
#2
|
||||
|
||||
|
var opt = Lform2.man1.options;
for(var i=0;i<opt;i++){ opt[i].selected=(Lform1.ckman1.value==opt[i].value)?true:false; } --------reedit-------- Last edited by Kor; 05-10-2006 at 10:34 AM. |
|
#3
|
|||
|
|||
|
Presuming that you've got FORM tags somewhere, change this part of your PHP code:
onclick=\" return setball()\" to this: onclick=\"return setball(this)\" Then, change your function to this: Code:
function setball(chkbox)
{
var Lform1= document.forms["advbbsearch1"];
var Lform2 = document.forms["advbbsearch2"];
Lform2.txtballname1.value = Lform1.ckb1.value;
if(chkbox.checked) {
var opt = Lform2.man1.options;
var x, len = opt.length;
for(x=0; x<len; ++x)
{
if(opt[x].value == Lform1.ckman1.value)
{
opt[x].selected = true;
break;
}
}
}
return true;
}
Last edited by phpnovice; 05-10-2006 at 10:34 AM. |
|
#4
|
|||
|
|||
|
thanks for reply I worked as you told but still it is not working...
so can you send me another solution please... |
|
#5
|
|||
|
|||
|
I can't provide anything else without any information as to just what is the problem. So, you provide a live link to your page on the Internet so I can see just what "is not working."
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|