Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help! - change option to checkbox...

Status
Not open for further replies.

sonicsnail

Technical User
Nov 10, 2001
48
IN
Thanks for the input everyone!.. however, they've moved the goalposts, and the job is slightly different now...

In short.. I have this - ... and I have to change the way it works...

The author created it so that the user would click on one of the entries in the <option>, then CTRL+click to add further ones.. and &quot;template(s)&quot; would appear in the <textarea> to be copied and pasted elsewhere...

The change I have to make seems pretty simple, but I think I have to mess with the variables and I'm not sure how to do it...

I have to replace the <option> box with mutliple <checkbox>'s, without losing the functionality. ie. Clicking the boxes will enter the relevant &quot;templates&quot; into the text area.

Anyone care to save my skin and send me on the right path?

Thanks in advance,

Pete
 
Here you go.. Go ahead and copy this on to your server, run it to see how it works, and let me know if you need any help understanding it or conforming it to your specific needs.

Code:
<html>
<head>
<script Language=&quot;JavaScript&quot;>
<!--
var messages0 = new Array(1); 

messages0[0] = &quot;Fix 1 Template&quot;;
messages0[1] = &quot;Fix 2 Template&quot;;
messages0[2] = &quot;Fix 3 Template&quot;; 
messages0[3] = &quot;Fix 4 Template&quot;;
messages0[4] = &quot;Fix 5 Template&quot;;
messages0[5] = &quot;Fix 6 Template&quot;;
messages0[6] = &quot;Fix 7 Template&quot;;
messages0[7] = &quot;Fix 8 Template&quot;;
messages0[8] = &quot;Fix 9 Template&quot;;
messages0[9] = &quot;Fix 10 Template&quot;;
function messageShow0(form_ref) {
  form_ref.messageBox.value = &quot;&quot;
  var messageValue = &quot;&quot;

  for (var i = 0; i < form_ref.elements.length; i++) {
    if (form_ref.elements[i].name == &quot;cbox&quot;) {
      if (form_ref.elements[i].checked == true) {
        messageValue += messages0[form_ref.elements[i].value] + &quot;\n\n&quot;
      }
    }
  }
  form_ref.messageBox.value = messageValue
}

//-->
</script>
</head>
<body>
<form>
<input onClick=&quot;messageShow0(this.form);&quot; type=&quot;checkbox&quot; name=&quot;cbox&quot; value=&quot;0&quot;>Fix 1</input><br>
<input onClick=&quot;messageShow0(this.form);&quot; type=&quot;checkbox&quot; name=&quot;cbox&quot; value=&quot;1&quot;>Fix 2</input><br>
<input onClick=&quot;messageShow0(this.form);&quot; type=&quot;checkbox&quot; name=&quot;cbox&quot; value=&quot;2&quot;>Fix 3</input><br>
<input onClick=&quot;messageShow0(this.form);&quot; type=&quot;checkbox&quot; name=&quot;cbox&quot; value=&quot;3&quot;>Fix 4</input><br>
<input onClick=&quot;messageShow0(this.form);&quot; type=&quot;checkbox&quot; name=&quot;cbox&quot; value=&quot;4&quot;>Fix 5</input><br>
<input onClick=&quot;messageShow0(this.form);&quot; type=&quot;checkbox&quot; name=&quot;cbox&quot; value=&quot;5&quot;>Fix 6</input><br>
<input onClick=&quot;messageShow0(this.form);&quot; type=&quot;checkbox&quot; name=&quot;cbox&quot; value=&quot;6&quot;>Fix 7</input><br>
<input onClick=&quot;messageShow0(this.form);&quot; type=&quot;checkbox&quot; name=&quot;cbox&quot; value=&quot;7&quot;>Fix 8</input><br>
<input onClick=&quot;messageShow0(this.form);&quot; type=&quot;checkbox&quot; name=&quot;cbox&quot; value=&quot;8&quot;>Fix 9</input><br>
<input onClick=&quot;messageShow0(this.form);&quot; type=&quot;checkbox&quot; name=&quot;cbox&quot; value=&quot;9&quot;>Fix 10</input><br><br>
<textarea cols=&quot;100&quot; rows=&quot;10&quot; name=&quot;messageBox&quot; wrap=&quot;virtual&quot; class=&quot;text&quot;></textarea>
</form>
</body>
</html>

Hope this helps.. :)

ToddWW
 
Thats perfect ToddWW! Thank you!

One more question... how could I make it so once boxes 1 to 9 are ticked, a submit button (or even img - anthing linkable) appears? (I need to keep box 10 seperate from this). I assume hiding a button behind a layer could do it?

thanks again.

Pete
 
Yeah, that may work. I'm not well versed in that area. There is a hide property that you can set to form elements that I have heard people talking about around here and if I remember correctly, it only works with IE.

So I'm thinking DHTML might be your best bet !!

ToddWW :)
 
Just thought - I could have the button on a hidden layer that appears once there are ticks in boxes 1 through 9.

anyone have any ideas how to achieve this?..

I'm guessing it'll be something along the lines of

&quot;IF 1,2,3,4,5,6,7,8,9 are ticked, THEN showlayer&quot;.. sort of thing...

 
Snail,

Problem here is that this thread is old and has too may replies. People are no longer looking at it..

Go ahead and post another thread and you'll get a rapid response.

ToddWW :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top