Hi All,

I'm working on the form which uses javascript field to generate radio
buttons, I need to to allow people to sort their entries as per
selected button:

Example

Text field:   James Martin Brown

We should have 3 buttons generated:
* James
* Martin
* Brown

Actually we should have:
* J
* M
* B

In the database I can store only 1 character to sort users.

Now if we select Brown (or B) button, our text field should change to
Brown James Martin (selected button should display first in the text
field) and then the rest of the text as was

At this point I've managed to get to the point where I have text field
which generates radio buttons and displays only 1st character (in the
database I can save only 1st character) what I need now is to be able
to use the sort button to change the order of the actual text in the
input text field - hope this makes sense ;)

My code:

 <td class="formlabel" align="left" valign="top">

  <script type="text/javascript">

  function update_radio_buttons() {
    var userName =
document.forms.contentForm.elements.data_name.value;
    var userName = userName.split(' ');
    var myRadioHTML = '';
    var startValue = '<%$value%>';
    for (var i =0; i < companyName.length; i++) {
      if (userName[i] != '') {
        var newRadioButton = '<p><input type="radio" name="<%$name%>"
value="' + userName[i].charAt(0) +'" />' + userName[i].charAt(0) + '</
p>';

        myRadioHTML = myRadioHTML + newRadioButton;
      }
    }
    document.getElementById("my_radio_buttons").innerHTML =
myRadioHTML;
  }
  </script>

then in the form I just use this code to call above function

<div id="my_radio_buttons"></div>
   <script type="text/javascript">
    update_radio_buttons();
   </script>

It would be great to see an example of such a code

many thanks

mck

Reply via email to