Results 1 to 6 of 6

Thread: Checkbox problem

  1. #1
    Join Date
    May 2008
    Posts
    9
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default Checkbox problem

    im new to this whole javascript thing.


    can anyone tell me how to to do this.

    im wanting to set up a checkbox so that when its selected it displays 400 in a seperate text box if its not selected it stays empty. Also additional to that i need a secondary checkbox that can be selected and display 600 in the before mentioned text box. i need it set up so that only one of these can be selected and displayed at a time.

    its for a booking fomr i need to do. cant suss out how to do this

  2. #2
    Join Date
    Feb 2008
    Location
    Cebu City Philippines
    Posts
    1,160
    Thanks
    17
    Thanked 277 Times in 275 Posts

    Default

    Could you rephrase it?..The question has two meaning:

    1.) When the checkboxes are clicked a "400" or "600" is displayed on a text box.

    2.) When the checkboxes are clicked a 400 or 600 textbox appears.

    I suppose it's no.1, See if this help:
    HTML Code:
    <script type="text/javascript"> 
    window.onload=function()
    {
    var check400=document.getElementById('check400'),
    check600=document.getElementById('check600'),
    output=document.getElementById('output');
    output.disabled='disabled';
    check400.onclick=function()
    	{
    	if(this.checked){
    	check600.checked=false;
    	output.value='400';
    	}else output.value='';
    	}
    check600.onclick=function()
    	{
    	if(this.checked){
    	check400.checked=false;
    	output.value='600';
    	}
    	else output.value='';
    	}
    }
    </script> 
    <input type="checkbox" name="mycheck" id="check400"><label>400</label>
    <input type="checkbox" name="mycheck" id="check600"><label>600</label>
    <br>
    <label>Shows Here: </label><input type="text" id="output">
    Learn how to code at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph!

  3. The Following User Says Thank You to rangana For This Useful Post:

    Vile Demonic (05-23-2008)

  4. #3
    Join Date
    May 2008
    Posts
    9
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default

    Yeah thats about right

    although i still cant get the 400 or 600 to appear in the box. I may be going about this a very difficult way.


    This is part of an open book assessment im doing and i cant figure out the simplest solution.

  5. #4
    Join Date
    Feb 2008
    Location
    Cebu City Philippines
    Posts
    1,160
    Thanks
    17
    Thanked 277 Times in 275 Posts

    Default

    Which is not working?..Could you show us your codes
    Learn how to code at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph!

  6. #5
    Join Date
    May 2008
    Posts
    9
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default

    ach i just deleted all the codes. think im going to start it all try find a more simple way.

    all i need is a way to display 400 or 600 either by using a check box or drop down menu in a seperate text box (like a total would) so it can be added onto another number (not always used) then display the total of those 2

  7. #6
    Join Date
    Feb 2008
    Location
    Cebu City Philippines
    Posts
    1,160
    Thanks
    17
    Thanked 277 Times in 275 Posts

    Default

    Whatever you decision is, just get back if you're still stumped
    Learn how to code at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph!

Bookmarks

Posting Permissions

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