Reply
input number output string??? how
Old 04-25-2008, 04:18 PM input number output string??? how
Novice Talker

Posts: 9
Name: kamsmartx
take this code
PHP Code:
<select name="FileNo" id="select2" onChange="change_title();"> 
    <?  
$query
="SELECT * FROM pationts"
$result=mysql_query($query) or die("error: " mysql_error()); 
while(
$row=mysql_fetch_array($result)) 

    echo 
"bla"
?>   
<option value="<?php echo $row['FileNo'] ; ?>"><?php echo $row['FileNo'] ; ?></option>    
<? 
    
}   
?> 
</select>
he above code is for list i need to select value from it and when i select value we must change vale on the below code
Code:
PHP Code:
<input name="PationtName" type="text" id="title"/> 
the result is :-
when i select FileNo:111 we print on PationtName: 111
this wrong we must print name of pationt who FileNo is 111
kamsmartx is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
     
Old 04-25-2008, 04:30 PM Re: input number output string??? how
Novice Talker

Posts: 9
Name: kamsmartx
any help
kamsmartx is offline
Reply With Quote
View Public Profile
 
Old 04-25-2008, 05:18 PM Re: input number output string??? how
tripy's Avatar
Fetchez la vache!

Posts: 1,849
Name: Thierry
Location: In the void
I have read 5 times your previous post, but I cannot understand what is happening right now and what you want...

You are in the javascript forum, so no need to post your php code.
Show us the javascript code, and explain logically and step by step what you need, how and from where and what is the current behavior of your script.
That way we will be able to help
__________________
Listen to the ducky: "This is awesome!!!"

tripy is offline
Reply With Quote
View Public Profile
 
Old 04-26-2008, 02:01 AM Re: input number output string??? how
Novice Talker

Posts: 9
Name: kamsmartx
ok
i wont print name of pationt on here

PHP Code:
<input name="PationtName" type="text" id="title"/> 
but when i select his fileNo from here
PHP Code:
<select name="FileNo" id="select2" onChange="change_title();">  
    <?   
$query
="SELECT * FROM pationts";  
$result=mysql_query($query) or die("error: " mysql_error());  
while(
$row=mysql_fetch_array($result))  
{  
    echo 
"bla";  
?>    
<option value="<?php echo $row['FileNo'] ; ?>"><?php echo $row['FileNo'] ; ?></option>     
<?  
    
}    
?>  
</select>
by using this java script

PHP Code:
function change_title(obj)
 { 
 
document.getElementById('PationtName').value obj.options[obj.selectedIndex].value;

but the script not print name , it print FileNo >> why
kamsmartx is offline
Reply With Quote
View Public Profile
 
Old 04-26-2008, 04:53 AM Re: input number output string??? how
tripy's Avatar
Fetchez la vache!

Posts: 1,849
Name: Thierry
Location: In the void
because:
PHP Code:
value="<?php echo $row['FileNo'] ; ?>"
put the fileNo value in the value attribute of the option.
So, when you do
Code:
</span>
obj.options[obj.selectedIndex].value;
, it's what you get.

Put the pationt value on the value, and it should be ok.
PHP Code:
<option value="<?php echo $row['pationt'] ; ?>"><?php echo $row['FileNo'] ; ?></option>
__________________
Listen to the ducky: "This is awesome!!!"

tripy is offline
Reply With Quote
View Public Profile
 
Old 04-26-2008, 08:49 AM Re: input number output string??? how
Novice Talker

Posts: 9
Name: kamsmartx
ok show what i do
on Javascript part i write this code
PHP Code:
function change_title(obj)
 { 
document.getElementById('title').value  document.getElementById('select2').options[selected_index].text;} 
and on body i write this code
PHP Code:
<select name="FileNo" id="select2" onChange="change_title();">   
    <?    
$query
="SELECT * FROM pationts";   
$result=mysql_query($query) or die("error: " mysql_error());   
while(
$row=mysql_fetch_array($result))   
{   
    echo 
"bla";   
?>     
<option value="<?php echo $row['Name'] ; ?>"><?php echo $row['FileNo'] ; ?></option>      
<?   
    
}     
?>   
</select>
and

PHP Code:
<input name="PationtName" type="text" id="title"/> 
but not print name of pationt why ??!!!!
kamsmartx is offline
Reply With Quote
View Public Profile
 
Old 04-26-2008, 09:50 AM Re: input number output string??? how
tripy's Avatar
Fetchez la vache!

Posts: 1,849
Name: Thierry
Location: In the void
your javascript is false. It should be
Code:
document.getElementById('title').value  = document.getElementById('select2').options[document.getElementById('select2').selected_index].value;}
or, as I find it clearer to read:
Code:
var sel=document.getElementById('select2');
document.getElementById('title').value=sel.options[sel.selectedIndex].value;
and now, it should be ok.
__________________
Listen to the ducky: "This is awesome!!!"

tripy is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to input number output string??? how
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.15149 seconds with 13 queries