Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

update inputbox with select box values using php and html  code

Posted on 2011-03-01
6
Medium Priority
?
548 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 800 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:Gurvinder Pal Singh
Gurvinder Pal Singh earned 400 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 7

Assisted Solution

by:Vimal DM
Vimal DM earned 800 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

963 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