Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 289 Vote(s) - 3.53 Average
  • 1
  • 2
  • 3
  • 4
  • 5
On Select Change href and Text

#1
I am trying to change price and href when user select from drop down menu which is working fine.

Now I want to change a text somewhere in the page.

**Change Text required here**

<div class="price">
<strong id="OrderLinkOne">2.00</strong>
<span>per month</span>
</div>

I am also using a PHP Function to make it more dynamic below is the function

$product_id1 = 5;
$product_id2 = 6;
$product_id3 = 7;
$product_id4 = 8;
$tenure = 12;

function SelectValue($price, $pid, $billingcycle){
$link ="http://project.dev/cart.php?a=add&pid=".$pid."&billingcycle="; // LIVE

if( $billingcycle == "1" ){
echo '<option value="'.$link.'monthly">1 Month at $'.$price.'/month</option>';
}

if( $billingcycle == "3" ){
echo '<option value="'.$link.'quarterly">3 Months at $'.$price.'/month</option>';
}

if( $billingcycle == "6" ){
echo '<option value="'.$link.'semiannually">6 Months at $'.$price.'/month</option>';
}

if( $billingcycle == "12" ){
echo '<option value="'.$link.'annually">12 Months at $'.$price.'/month</option>';
}

if( $billingcycle == "24" ){
echo '<option value="'.$link.'biennially">24 Months at $'.$price.'/month</option>';
}

if( $billingcycle == "36" ){
echo '<option selected="selected" value="'.$link.'triennially">36 Months at $'.$price.'/month</option>';
}

}

function SelectPrice($HTMLID, $pid, $billingcycle){
$link ="http://project.dev/cart.php?a=add&pid=".$pid."&billingcycle="; // LIVE

if( $billingcycle == "1" ){
echo '<a id="'.$HTMLID.'" href="'.$link.'monthly">Buy Now</a>';
}

if( $billingcycle == "3" ){
echo '<a id="'.$HTMLID.'" href="'.$link.'quarterly">Buy Now</a>';
}

if( $billingcycle == "6" ){
echo '<a id="'.$HTMLID.'" href="'.$link.'semiannually">Buy Now</a>';
}

if( $billingcycle == "12" ){
echo '<a id="'.$HTMLID.'" href="'.$link.'annually">Buy Now</a>';
}

if( $billingcycle == "24" ){
echo '<a id="'.$HTMLID.'" href="'.$link.'biennially">Buy Now</a>';
}

if( $billingcycle == "36" ){
echo '<a id="'.$HTMLID.'" href="'.$link.'triennially">Buy Now</a>';
}
}

**My JS:**

$(document).ready(function(){
$("#planOne").change(function () {
console.log(this.value);
$("#OrderLinkOne").attr('href', this.value);
});
});

**HTML**

<div class="select-tenure">
<select id="planOne">
<?php echo SelectValue("2.08", $product_id1, 12);?>
<?php echo SelectValue("2.00", $product_id1, 24);?>
<?php echo SelectValue("2.00", $product_id1, 36);?>
</select>
</div>

<div class="link">
<?php echo SelectPrice("OrderLinkOne", $product_id1, 36);?>
</div>

When I change from dropdown the link is wokring fine but I want to change only price under `.price` class so please provide a solution how to show only price instead of complete value of an option...
Reply

#2
This is what you need.

`$(".price").children("strong").text("3.00"); //change the value 2.00`


`$("span").text("per week"); // change the text within the span`

You can use `if` or `switch` to change the value based on the user choice.

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-js -->

$(document).ready(function(){
$("#planOne").change(function () {
console.log(this.value);
$("#OrderLinkOne").attr('href', this.value);
$(".price").children("strong").text("3.00");
$("span").text("per week");
});
});

<!-- language: lang-html -->

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="price">
<strong>2.00</strong>
<span>per month</span>
</div>

<select id="planOne">
<option value="google.com">Google</option>
<option value="microsoft.com">Microsoft</option>
<option value="yahoo.com">Yahoo</option>
</select>
<a id="OrderLinkOne" href="google.com">Link</a>

<!-- end snippet -->

Reply

#3
Okay for a simple solution you can write the code like:

$(document).ready(function(){
$("#planOne").change(function () {
console.log(this.value);
$("#OrderLinkOne").attr('href', this.value);
$("#PriceOne").html('1000'); // you can turn this interger in what you want
});
});

now you can change your price in every integer you want.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through