Beste SD'ers,
Ik heb momenteel een script die ik wat wil uitbreiden. Maar ik loop even vast en hoop dat er hier een slim(mer) persoon rond loopt :)
Bij een klik op de knop "plaats bod" wordt de waarde uit de text box gedistilleerd door een function. Nu wil ik het tekst veld graag vervangen door 3 buttons.
Bij de onclick wordt de function flaceManualBidConfirm aangeroepen, die op zijn beurt weer andere functies aanroept..Code:html += '<input type="button" value="<?php echo $button_place_bid; ?>" id="button-place-bid" alt="<?php echo $button_place_bid; ?>" title="<?php echo $button_place_bid; ?>" class="button" onclick="placeManualBidConfirm(<?php echo $auction_id; ?>);" <?php echo $bid_disabled; ?> />'; html += '<span> <?php echo $text_for; ?> </span>'; html += '<input type="text" name="bid_amount" value="1" size="10" maxlength="20" <?php echo $bid_disabled; ?>';
Momenteel heb ik dus een invul veld waar ik een waarde kan invullen, en vervolgens bevestigen met een druk op de knop.Code:function placeManualBidConfirm(auction_id) { var bid_amount = parseFloat($('input[name=\'bid_amount\']').val()); $('#button-place-bid').prop('disabled', 'disabled'); if (bid_amount < currentAuctionNextBidAmount) { showErrorOnBidFailure(modalAuctionBidNotEnough.replace('%s', formatNumber(currentAuctionNextBidAmount, defaultCurrencyDecimalPlace, defaultCurrencyDecimalPoint, '')), false); } else if (bid_amount > originalAuctionBuyoutPrice && originalAuctionBuyoutPrice > 0) { showConfirmationPrompt(modalAuctionBidBuyoutInstead, '$(\'input[name=\\\'bid_amount\\\']\').val(originalAuctionBuyoutPrice); placeManualBid(' + auction_id + ');'); } else { placeManualBid(auction_id); } $('#button-place-bid').removeProp('disabled'); function placeManualBid(auction_id) { var bid_amount = parseFloat($('input[name=\'bid_amount\']').val()); var auth = encodeURIComponent(Sha1.hash(String(parseInt(Math.floor(new Date().getTime() / 1000) + serverClientTimeDiff)))); var curl = 'index.php?route=product/auction/auctionplacebid&auth=' + auth + '&auction_id=' + auction_id + '&bid_amount=' + bid_amount; $.ajax({ url: curl, cache: false, async: false, success: function(result) { if (!isNaN(result) && result > 0) { updateManualBidding(); } else { if (result == -1) { showErrorOnBidFailure(modalAuctionBidNotEnough.replace('%s', formatNumber(currentAuctionNextBidAmount, defaultCurrencyDecimalPlace, defaultCurrencyDecimalPoint, '')), false); } else if (result == -2) { showErrorOnBidFailure(modalAuctionDataCorrupted, true); } else if (result == -3) { showErrorOnBidFailure(modalAuctionBidAlreadyHighest, false); } else if (result == -4) { showErrorOnBidFailure(modalAuctionJustEnded, true); } else if (result == -5) { showErrorOnBidFailure(modalAuctionNotActive, true); } else if (result == -6) { showErrorOnBidFailure(modalAuctionNotFound, true); } else if (result == -7) { showErrorOnBidFailure(modalAuctionNoParameters, true); } else if (result == -8) { showErrorOnBidFailure(modalAuctionNotLogin, true); } else if (result == -9) { showErrorOnBidFailure(modalAuctionConnectionLost, false); } else { showErrorOnBidFailure(modalAuctionBidAttemptFail, false); } } } }); } function updateManualBidding() { $('input[name=\'bid_amount\']').stop(true, true).effect('transfer', {to: $('#auction-amount'), className: 'ui-effects-transfer'}, defaultAnimationFast); }
Ik wil er dus naar toe dat ik 3 knoppen krijg met elk een eigen value. De variabele 'bid_amount' zal dus gevuld moeten worden aan de hand van welke knop er gedrukt wordt.
Iemand die mij (gedeeltelijk) op weg kan helpen?
- herschrijven function
-
31-10-2014, 20:49 #1
- Berichten
- 243
- Lid sinds
- 15 Jaar
herschrijven function
-
-
12-11-2014, 08:04 #2
- Berichten
- 94
- Lid sinds
- 17 Jaar
Re: herschrijven function
Geef aan de functie "function placeManualBidConfirm(auction_id)" een extra parameter mee die de "bid_amount" is. Dan hoef je deze niet meer uit het textveld te lezen maar krijg je deze fixed per knop binnen.
-
14-11-2014, 09:22 #3
- Berichten
- 243
- Lid sinds
- 15 Jaar
Re: herschrijven function
Opgelost
Plaats een
- + Advertentie
- + Onderwerp
Marktplaats
Webmasterforum
- Websites algemeen
- Sitechecks
- Marketing
- Domeinen algemeen
- Waardebepaling
- CMS
- Wordpress
- Joomla
- Magento
- Google algemeen
- SEO
- Analytics
- Adsense
- Adwords
- HTML / XHTML
- CSS
- Programmeren
- PHP
- Javascript
- JQuery
- MySQL
- Ondernemen algemeen
- Belastingen
- Juridisch
- Grafisch ontwerp
- Hosting Algemeen
- Hardware Info
- Offtopic