Click here to Skip to main content
15,942,292 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Actually i am working on a project and i am new in php..i cant understand how i have to do.. i want to select value in textbox according to other text box means if i fill id textbox den automatically name textbox will fill.. i got the textbox value but dont know how to store testbox value without submitting form in php
my code is like:---
<pre lang="Javascript">
<script language='JavaScript'>
function getwords(){
myOutput=document.getElementById('output');
textbox = document.getElementById('c_id');
if (textbox.value != "")
myOutput.innerHTML=textbox.value;
else
alert('<?php echo "No word has been entered!";?>')
}
</script>

<pre lang="PHP">
<tr>
            <td>User_ID</td>
            <td><label>
              <input name="c_id" type="text" id="words"  önChange="getwords()">
            </label></td>
          </tr>
<div id="output"></div>
          <tr>
            <td>Name </td>
            <td><label>
              <input name="fname" type="text" id="noi" >
            </label></td>
          </tr>


now what i have to do...please reply me as soon as possible..
Thanks
Posted
Comments
[no name] 16-May-12 8:40am    
"as soon as possible" is considered rude here. This is a volunteer site and people will answer on their time, not yours.
Wendelius 16-May-12 17:24pm    
Agree.

Try this



JavaScript
XML
<script language='JavaScript' type="text/javascript">
       function getwords() {


               document.getElementById('TextBox2').value = document.getElementById('TextBox1').value;

       }
   </script>


Html (aspx)
XML
<asp:TextBox ID="TextBox1" runat="server" ></asp:TextBox>
        <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
        <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />


Code behind (aspx.cs)
C#
protected void Page_Load(object sender, EventArgs e)

{
TextBox1.Attributes.Add("Onblur", "getwords()");
}

C#
protected void Button1_Click(object sender, EventArgs e)
      {
          string test = TextBox2.Text;
      }
 
Share this answer
 
v2
try this,
1.double click textbox
2.set autopostback="true"

example:

sample.aspx
<asp:textbox id="TextBox1" runat="server" ontextchanged="TextBox1_TextChanged" autopostback="true" xmlns:asp="#unknown">


sample.aspx.cs
C#
protected void TextBox1_TextChanged(object sender, EventArgs e)
        {
//to pass the value of a control to another control
session["textboxvalue"]=TextBox1.Text;

        }
 
Share this answer
 
Try this
XML
<pre lang="Javascript">
<script language="'JavaScript'">
function getwords(){
myOutput=document.getElementById('output');
textbox = document.getElementById('c_id');
if (textbox.value != "")
document.getElementById('output').value = textbox.value;
else
alert('<?php echo "No word has been entered!";?>')
}
</script>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900