SkyRanger Posted April 26, 2007 Share Posted April 26, 2007 What I need (Been searching for 3 days now) User clicks on form field ie: radio button and it echos the value into a textbox. Can you do this in php or is it on a javascript function? Link to comment https://forums.phpfreaks.com/topic/48723-solved-is-there/ Share on other sites More sharing options...
sw0o0sh Posted April 26, 2007 Share Posted April 26, 2007 um... that would be a very EASY onclick ajax function. Lol Wait, no server needed stuff here, this is what you could do. <script type='text/javascript'> <!-- function echo_text(radio_id){ var input = document.getElementById('radio' + radio_id).value; document.getElementById('textarea_id').value = input; } //--> </script> <input type='radio' onclick='echo_text("1")' value='my_first_radio' name='whatever' id='radio1' /> <input type='radio' onclick='echo_text("2")' value='my_second_radio' name='whatever' id='radio2' /> <textarea id='textarea_id'></textarea> Link to comment https://forums.phpfreaks.com/topic/48723-solved-is-there/#findComment-238771 Share on other sites More sharing options...
rallokkcaz Posted April 26, 2007 Share Posted April 26, 2007 beat me to it sw0o0sh lol Link to comment https://forums.phpfreaks.com/topic/48723-solved-is-there/#findComment-238777 Share on other sites More sharing options...
sw0o0sh Posted April 26, 2007 Share Posted April 26, 2007 also replied in your thread to >_> Also, to the owner of this topic, theres a more automatic way to tell based on if the radio was checked instead of manually defining the id number extension in the onclick function, however im no god at javascript. So there is a bit more of an easier way to write this, but meh, next guy can handle that if writing "1" "2" "3" etc inside the function is to much for you Link to comment https://forums.phpfreaks.com/topic/48723-solved-is-there/#findComment-238781 Share on other sites More sharing options...
SkyRanger Posted April 26, 2007 Author Share Posted April 26, 2007 Yeah, the problem is that I am pulling all of the info from mysql for the radio buttons: echo "<input type='radio' onclick='echo_text()' value='".$rowab['abname']." id='radio1'>".$rowab['abname'].""; Link to comment https://forums.phpfreaks.com/topic/48723-solved-is-there/#findComment-238782 Share on other sites More sharing options...
SkyRanger Posted April 26, 2007 Author Share Posted April 26, 2007 Now the radio button won't click with that code Link to comment https://forums.phpfreaks.com/topic/48723-solved-is-there/#findComment-239067 Share on other sites More sharing options...
SkyRanger Posted April 26, 2007 Author Share Posted April 26, 2007 Got it to work another way. If anybody is looking for something like this. Look in the Javascript help forum under http://www.phpfreaks.com/forums/index.php/topic,137471.0.html Link to comment https://forums.phpfreaks.com/topic/48723-solved-is-there/#findComment-239259 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.