Solved

update inputbox with select box values using php and html  code

Posted on 2011-03-01
6
544 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
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 learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

622 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