homepage Welcome to WebmasterWorld Guest from 54.198.139.141
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld
Home / Forums Index / Code, Content, and Presentation / HTML
Forum Library, Charter, Moderators: incrediBILL

HTML Forum

    
How to get checkboxes and not dropdown
Silver007A




msg:4611849
 8:30 pm on Sep 22, 2013 (gmt 0)

Hi,

I'm trying to create checkboxes and not dropdown options in this calculator. Can anyone help please?

Thanks

<form name="calTable">
<select name="select1">
<option>Select</option>
<option name="interview" value="11">Interview</option>
<option name="focus" value="12">Focus</option>
</select>
<br>
<select name="select2">
<option>Select</option>
<option name="normal" value="21">Normal</option>
<option name="priority" value="22">Priority</option>
</select>
<br>
<span>Total No. of Minutes</span>
<br>
<input type="text" name="num" placeholder="enter valid no" value="">
</form>
<script>
function calc(){
var sel1 = document.calTable.select1.value;
var sel2= document.calTable.select2.value;
var num=document.calTable.num.value;

if(sel1==11 && sel2==21){var val=num*1.10;}
if(sel1==11 && sel2==22){var val=num*1.30;}
if(sel1==12 && sel2==21){var val=num*1.30;}
if(sel1==12 && sel2==22){var val=num*1.50;}

document.getElementById("output").innerHTML = val;
};
</script>
<input type="button" onclick="calc();" value="calculate Total cost" >
&nbsp &nbsp &nbsp<div id="output"> Total Cost</div>

 

lucy24




msg:4611860
 10:17 pm on Sep 22, 2013 (gmt 0)

Heh. It's the rarely seen Too Little Information.

My first reaction was "If you want checkboxes, why does the code call for 'select', which means dropdowns?" My second reaction was: How can you use checkboxes if each category has two or more mutually exclusive options? For that you'd need radio buttons if you want something visible. (Yes, technically you could use checkboxes, but then you'd also need a bunch of extra code to ensure that the user has selected exactly one item in each category.)

That takes us to answer #3: You gotta give us a hint. How much about forms do you already know? Is this an existing form of your own that you want to tweak, or something you found online and you have no idea what part does what?

The quoted form is done within javascript. But this is the /html/ forum. Does that mean it's fundamentally an HTML question-- which it easily could be-- or that you goofed when clicking New Topic?

Silver007A




msg:4611955
 8:13 am on Sep 23, 2013 (gmt 0)

Yeah, sorry. It's been a long time since I posted on a forum like this.

One of my team has created this calculator. However, between us, we don't know how to get radio buttons.

I'm not sure if this is an html question or java.

Thanks again for you help.

lucy24




msg:4611969
 9:19 am on Sep 23, 2013 (gmt 0)

Well, the horse's mouth is here
[w3.org...]
but frankly their html pages scare me to death. (The css pages are fine.)

Quick cut-and-paste from the nearest form I've got handy:

<input type = "radio" name = "keepdate" value = "fulldate">Full Date<br>
<input type = "radio" name = "keepdate" value = "divider" checked = "checked">Divider<br>
<input type = "radio" name = "keepdate" value = "none">Nothing

and

<input type = "checkbox" name = "keepline" value = "opt_ip">IP<br>
<input type = "checkbox" name = "keepline" value = "opt_mth">Method<br>
<input type = "checkbox" name = "keepline" value = "opt_page">Page<br>

Note the name of each item. Forms are one of the few places the name attribute is still used. To keep radio buttons together, they all have to have the same name.

ileaddigital




msg:4627735
 10:22 am on Dec 4, 2013 (gmt 0)


Try this thread for your requirements

code.google.com/p/dropdown-check-list/

Hope this will help you! Thanks,

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / HTML
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved