...

View Full Version : Sharing field values



h8ids
06-06-2007, 04:42 PM
I have an INPUT field which calls the following function; dup.
The function should do two things:
1) write the field value to the page - This works beautifully
2) share textfield INPUT value with INPUT radio button - Not working

I can't give both INPUTs the same id.



<script>
function dup(what)
{
//THIS WORKS BEAUTIFULLY
var createText = document.createTextNode(what);
var cell = document.getElementById('sameName');
if(cell.hasChildNodes())
{ while(cell.childNodes.length >= 1 )
{ cell.removeChild( cell.firstChild ); } }
cell.appendChild(createText);

//PROBLEM CODE HERE - trying to share value of Instructor with FacultyName
var Teacher = document.forms["form1"]["Instructor"];
document.forms["FacultyName"] = Teacher.value;
}
</script>

<!-- INPUT textfield -->
<input id="Instructor" type="text" name="Instructor" value="" onBlur="dup(this.value)">

<!-- Radio button INPUT -->
<input checked type="radio" name="FacultyName" id="Name" value="">

brandonH
06-06-2007, 08:48 PM
do a function that will grab the value of the text field after every kestroke (use onkeyup on the text field) the function should grab the value and then set it to the radio buttons value.


example:





<input type=text id=text1 value='' onkeyup="sharevalue(this.value);">
<input type=radio checked id=radio1 value=''>
<script type=text/javascript>

function sharevalue(val){
document.getElementById('radio1').value=val;
}

</script>




the above is just an example and im sure you want to work on multiple textfields/radio buttons. but this should get you pointed in the right direction.

h8ids
06-06-2007, 09:55 PM
I'll play with it and see what can be done. Thanks!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum