Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jan 2006
    Posts
    251
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Sharing field values

    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.

    Code:
    <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="">

  • #2
    Regular Coder
    Join Date
    Oct 2003
    Location
    on a ship
    Posts
    574
    Thanks
    1
    Thanked 6 Times in 5 Posts
    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:



    Code:
    <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.
    I make no attempt at pretending like I'm a professional. I offer help with what knowledge I do have.

  • #3
    Regular Coder
    Join Date
    Jan 2006
    Posts
    251
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up

    I'll play with it and see what can be done. Thanks!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •