Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    Regular Coder
    Join Date
    Aug 2012
    Posts
    112
    Thanks
    6
    Thanked 0 Times in 0 Posts

    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!

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,189
    Thanks
    75
    Thanked 4,341 Times in 4,307 Posts
    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.

  • #3
    Regular Coder
    Join Date
    Aug 2012
    Posts
    112
    Thanks
    6
    Thanked 0 Times in 0 Posts
    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!

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,189
    Thanks
    75
    Thanked 4,341 Times in 4,307 Posts
    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.

  • #5
    Regular Coder
    Join Date
    Aug 2012
    Posts
    112
    Thanks
    6
    Thanked 0 Times in 0 Posts
    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.

  • #6
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,189
    Thanks
    75
    Thanked 4,341 Times in 4,307 Posts
    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.

  • #7
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,189
    Thanks
    75
    Thanked 4,341 Times in 4,307 Posts
    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.

  • #8
    Regular Coder
    Join Date
    Aug 2012
    Posts
    112
    Thanks
    6
    Thanked 0 Times in 0 Posts
    That works great. Thanks!


  •  

    Tags for this Thread

    Posting Permissions

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