Solved

update inputbox with select box values using php and html  code

Posted on 2011-03-01
6
540 Views
Last Modified: 2012-05-11
i have a slect box and after it has changed it would copy the vlaue in one input box into another.
as well as hit the button and it will copy the value of the selct box into the other input box.
i have provided the code below just cannot seem to get them to operate off the select box
any help would be appreciated thanks
<input class="textinput" maxlength="255" name="caschild2editAinp" id="caschild2editAinp_id" size="40" />
	<input class="textinput" value="test data" maxlength="255" name="caschild2editBinp" id="caschild2editBinp_id" size="40" />
	
	<select class="select" style="width: 250px" name="caschild2editA" id="caschild2editA_id"
			onchange=alert("fff")
			this.form.caschild2editAinp.value = this.form.caschild2editBinp.value;
			><option value='10875' >Accounting-Business Management</option><option value='10877' >State Arts Associations</option></select>
	
	<td><br></br>
	<input class="textinput" maxlength="255" name="testloadfromselect" id="testloadfromselect_id" size="40" />
	<input type=button value='Use Value >>'
		onclick='this.form.caschild2editAinp.value = this.form.caschild2editA.value;'>
	</td>			    		

Open in new window

0
Comment
Question by:sydneyguy
6 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 200 total points
ID: 35006968
put this in head section of your page :

function doTheCopy(obj) {
   alert("fff");
   document.getElementById("caschild2editAinp_id").value = document.getElementById("caschild2editBinp_id").value;
}

Open in new window


0
 
LVL 40

Assisted Solution

by:gurvinder372
gurvinder372 earned 100 total points
ID: 35006980
replace line 5-6 by

onchange="document.getElementById('caschild2editAinp_id').value = document.getElementById('caschild2editBinp_id').value";
0
 
LVL 82

Expert Comment

by:leakim971
ID: 35007039
>put this in head section of your page :

inside script tag of course :)

<script language="javascript">
function doTheCopy(obj) {
   alert("fff");
   document.getElementById("caschild2editAinp_id").value = document.getElementById("caschild2editBinp_id").value;
}
</script>

Open in new window

0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
LVL 7

Assisted Solution

by:Vimal DM
Vimal DM earned 200 total points
ID: 35009192
Hai,

Find below code, just copy and execute those lines

<script language="javascript" type="text/javascript">
      function setSelectedVal(){
        var selObj = document.getElementById("caschild2editA");
        var val = selObj.options[selObj.selectedIndex].value;
        document.getElementById("caschild2editBinp").value = val;       
      }
      
      function setUseVal(){       
        document.getElementById("testloadfromselect").value = document.getElementById("caschild2editBinp").value;       
      }
</script>
<input class="textinput" maxlength="255" name="caschild2editAinp" id="caschild2editAinp_id" size="40" />
      <input class="textinput" value="test data" maxlength="255" name="caschild2editBinp" id="caschild2editBinp_id" size="40" />      
      <select class="select" style="width: 250px" name="caschild2editA" id="caschild2editA" onchange="setSelectedVal()">
      <option value='10875' >Accounting-Business Management</option><option value='10877' >State Arts Associations</option></select>
      <td><br></br>
      <input class="textinput" maxlength="255" name="testloadfromselect" id="testloadfromselect_id" size="40" />
      <input type=button value='Use Value >>'
            onclick="setUseVal()">
      </td>            
0
 

Author Comment

by:sydneyguy
ID: 35013646
i can get the code going while its static on the page and have the code below where the first section works and displays the info on the select box, section 2 displays the second data but does not work, where this select has been dynamicaly built via ajax to work with the above cascade.
function showSelected()
{
//  section 1
      alert("in");
      var selObj = document.getElementById('casparent1edit_id');
      var selIndex = selObj.selectedIndex;
      alert(selIndex)
      alert(selObj.options[selIndex].value);
      alert(selObj.options[selIndex].text);
// section 2      
var selObj = document.getElementById('caschild1edit_id');
      var selIndex = selObj.selectedIndex;
      alert(selIndex)
      alert(selObj.options[selIndex].value);
      alert(selObj.options[selIndex].text);
}
      
0
 

Author Closing Comment

by:sydneyguy
ID: 35013972
ok its going well thanks for every ones input, bit of every ones input to get me going, put the system back to getther and cleaned up my page and the code and that now works well , did my call from the onchange and the dynamic now works spot on so thanks for all your help

function settypeC(){
      var selObj = document.getElementById('caschild2editC');
      var selIndex = selObj.selectedIndex;
      document.getElementById('caschild2editCval').value = selObj.options[selIndex].text;
}
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now