Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



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

Posts: 9
Name: kamsmartx
Trades: 0
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
 
 
Register now for full access!
Old 04-25-2008, 05:30 PM Re: input number output string??? how
Novice Talker

Posts: 9
Name: kamsmartx
Trades: 0
any help
kamsmartx is offline
Reply With Quote
View Public Profile
 
Old 04-25-2008, 06:18 PM Re: input number output string??? how
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
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
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 04-26-2008, 03:01 AM Re: input number output string??? how
Novice Talker

Posts: 9
Name: kamsmartx
Trades: 0
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, 05:53 AM Re: input number output string??? how
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
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>
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 04-26-2008, 09:49 AM Re: input number output string??? how
Novice Talker

Posts: 9
Name: kamsmartx
Trades: 0
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, 10:50 AM Re: input number output string??? how
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
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.
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Reply     « Reply to input number output string??? how
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB 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.26294 seconds with 12 queries