Jump to content
puggybelle

Is there a way to make text or a symbol static in a form field?

Recommended Posts

I'm trying to put together something to use a Best Offer option in my website.  Yes, I'm riffing on what eBay is doing with their listings.

So far, I've got the offer button at the bottom of the product_info pages.  Like this in my test site:

1950860393_offerbutton.PNG.25530ac8a30e249a8be630c900fcc428.PNG

When you click that button for Make An Offer, you get a popup which overlays the product_info screen you're on:

886859072_offerform.PNG.7b46bfad0babf407466c2a5decd2b07e.PNG

I've got the Best Offer Price field populated from the start with the $ symbol, but when you type in your dollar amount...and change your mind and back over the whole field...the dollar sign disappears.

Is there a way to make that stick?  Like mud?  It never goes away?  You can only back over and change the price you originally entered, but...the $ sign never goes away?

The code I'm using for that field looks like this:

<?php
        echo tep_draw_input_field('enquiry', '$', 0, 1, NULL, 'required aria-required="true" maxlength="6" id="inputEnquiry" placeholder="' . ENTRY_OFFER_TEXT . '"');
        echo FORM_REQUIRED_INPUT;
        ?>&nbsp;&nbsp;&nbsp;shipping not included
                                </div>

What I'm doing is kind of a mash-up of the Contact Us form.  And all credit in the world goes to @JcMagpie for getting me rolling.  I just can't figure out how to make that dollar sign stick.  Is that possible?  I don't know how.  And he's asleep, otherwise I'd be driving him crazy.  Any help is appreciated!

- Andrea

Share this post


Link to post
Share on other sites
Posted (edited)

This could be achieved with javascript. But it's much easier to just show the $ sign permanent outside before the inputfield.

<?php
        echo '$ ' . tep_draw_input_field('enquiry', '', 0, 1, NULL, 'required aria-required="true" maxlength="6" id="inputEnquiry" placeholder="' . ENTRY_OFFER_TEXT . '"');
        echo FORM_REQUIRED_INPUT;
        ?>   shipping not included
                                </div>

 

Edited by raiwa

Share this post


Link to post
Share on other sites

You should find that the place holder will only disappear when you type in that filed. If you then erase what you type and press enter it will reappear, that is how it works.

 


 

Share this post


Link to post
Share on other sites

You could use input group as alternative solution.

This is an example code from the bootstrap site. Adjust that to match what you need. 

<div class="input-group">
  <span class="input-group-addon" id="basic-addon1">@</span>
  <input type="text" class="form-control" placeholder="Username" aria-describedby="basic-addon1">
</div>

 

Share this post


Link to post
Share on other sites

If "parking" the currency sign just outside (before) the field isn't desirable, it might be possible to do it in Javascript. At each keystroke within the field, you'd check the string value, and if it's missing the currency sign in the right place, force it to be added to the string. This ought to work too for currencies that are after the amount.

Is it critical that the currency sign be in the text field itself, or can it be added on later (in the PHP code processing the form input), if missing?


If you are running the "official" osC 2.3.4 or 2.3.4.1 download, your installation is obsolete! Get (stable) Frozenpatches or (unstable) Edge. See also the naming convention and the latest community-supported responsive "Edge" release

Share this post


Link to post
Share on other sites
25 minutes ago, MrPhil said:

Is it critical that the currency sign be in the text field itself, or can it be added on later (in the PHP code processing the form input), if missing?

Not at all.  This is just me getting tedious about minor cosmetic things.  And learning how to manipulate code.  That's the fun part!

I'm going to play around with the suggestions I've received and see what makes me happiest. 

Thanks everybody!

- Andrea

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×