Solved

update inputbox with select box values using php and html  code

Posted on 2011-03-01
6
538 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
Comment Utility
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
Comment Utility
replace line 5-6 by

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

Expert Comment

by:leakim971
Comment Utility
>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 Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 7

Assisted Solution

by:Vimal DM
Vimal DM earned 200 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
ust html in ms/access WebBrowswer 11 41
Detecting robots? 5 33
resizeing PHP image 2 21
Instering to MySQL table 5 15
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

772 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

15 Experts available now in Live!

Get 1:1 Help Now