Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-18-2012, 01:20 AM   PM User | #1
Ilan
New Coder

 
Join Date: Aug 2012
Posts: 87
Thanks: 4
Thanked 0 Times in 0 Posts
Ilan is an unknown quantity at this point
Hiding A Middle Field (go from A to C)

Hi everyone!

I have a converter that I'm working on here: http://www.payitforwardfriends.com/converter.html

When a user selects a product its density is put into the field. This density is then used to make calculations to convert from cups to grams etc.

How do I get rid of the density field? I don't want people to be able to type in their own density or see that field at all.

Thanks so much!
Ilan is offline   Reply With Quote
Old 08-18-2012, 01:23 AM   PM User | #2
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,237
Thanks: 59
Thanked 3,998 Times in 3,967 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
So why even have the field? Or the units <select>???

Or is it that you want people to be able to use those fields but only if they do *NOT* make a selection from "Substance"???
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Old 08-18-2012, 01:26 AM   PM User | #3
Ilan
New Coder

 
Join Date: Aug 2012
Posts: 87
Thanks: 4
Thanked 0 Times in 0 Posts
Ilan is an unknown quantity at this point
Hi Old Pedant,

I took a code and have been making lots of changes to it to suit my needs. I can't figure out to get rid of this part.

Thanks!
Ilan is offline   Reply With Quote
Old 08-18-2012, 01:27 AM   PM User | #4
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,237
Thanks: 59
Thanked 3,998 Times in 3,967 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
So just remove those fields from the page.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Old 08-18-2012, 01:29 AM   PM User | #5
Ilan
New Coder

 
Join Date: Aug 2012
Posts: 87
Thanks: 4
Thanked 0 Times in 0 Posts
Ilan is an unknown quantity at this point
I've tried that. The problem is that the code uses the value in the field to do the calculations. If I remove the field, then nothing shows up.
Ilan is offline   Reply With Quote
Old 08-18-2012, 01:32 AM   PM User | #6
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,237
Thanks: 59
Thanked 3,998 Times in 3,967 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
Ehh...but you clearly would then be even more lost on how to change the JavaScript code to account for them being missing, right?

Okay...so just change all this:
Code:
	<td align="center">
		<INPUT id="density" type="text" value="1" size="12" onFocus="resetdensityForm();"><br>
		<select id="densunit" onchange="checkcopydensity()">
			<option value="240">grams/cup</option>
			<option selected value="1">g/cm³</option>
			<option value="1">g/ml</option>
			<option value="1">kg/L</option>
			<option value="1000">kg/m³</option>
			<option value="160.358605679368">oz/gal [UK]</option>
			<option value="133.526471232309">oz/gal [US]</option>
			<option value="62.4279605761446">lb/ft³</option>
			<option value="0.0361272920000837">lb/in³</option>
		</select >
	</td>
To thie:
Code:
	<td align="center">
		<input id="density" type="hidden" value="1" />
		<input id="densunit" type="hidden" value="1" />
	</td>
That's the simplest possible change.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Old 08-18-2012, 01:34 AM   PM User | #7
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,237
Thanks: 59
Thanked 3,998 Times in 3,967 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
Actually, I guess the simplest possible change is this:
Code:
	<td style="display: none;" align="center">
		<INPUT id="density" type="text" value="1" size="12" onFocus="resetdensityForm();"><br>
		<select id="densunit" onchange="checkcopydensity()">
			<option value="240">grams/cup</option>
			<option selected value="1">g/cm³</option>
			<option value="1">g/ml</option>
			<option value="1">kg/L</option>
			<option value="1000">kg/m³</option>
			<option value="160.358605679368">oz/gal [UK]</option>
			<option value="133.526471232309">oz/gal [US]</option>
			<option value="62.4279605761446">lb/ft³</option>
			<option value="0.0361272920000837">lb/in³</option>
		</select >
	</td>
Just add the code in red there.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Old 08-18-2012, 01:42 AM   PM User | #8
Ilan
New Coder

 
Join Date: Aug 2012
Posts: 87
Thanks: 4
Thanked 0 Times in 0 Posts
Ilan is an unknown quantity at this point
That works great. Thanks!
Ilan is offline   Reply With Quote
Reply

Bookmarks

Tags
field, javascript, middle

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:40 AM.


Advertisement
Log in to turn off these ads.