0

can you please help me with this ? i have some packages and for each package there is a price the package name in column name the package price is in column price i need to when client clicked on contact us, redirected to me via WhatsApp with message in it the package name and the package price like this : https://api.whatsapp.com/send?phone=123456789&text= Hello, i want to ask about the package (val.name) with its price (val.price) i have this problem :

 <div class="col hidden" id="sub-container0">
     <div class="card">
        <div class="card-body">
           <h5 class="card-title sup-header">Special title treatment</h5>
           <div class="card-text sup-price-pr"></div>
             <div class="card-text sup-number-pr"></div>
           <div class="card-text sup-months"></div>
       <div class="card-text sup-total"></div>
           <a class="choose_package btn btn-primary mt-2" title="" target="_blank" id="real_link_wa" href="https://api.whatsapp.com/send?phone=123456789&amp;text="><?php echo $this->lang->line("contact us"); ?> <i class="fab fa-whatsapp fa-lg"></i></a>
        </div>
         </div>
       </div>

and in java :

 $('#sub-container'+key+' > div.card > div > div.card-text.sup-total').html("<?php echo $this->lang->line("total price"); ?>: "+parseInt(val.price))
 $('#sub-container'+key+' > div.card > div > div.card-text.sup-price-pr').html("<?php echo $this->lang->line("price client"); ?> : "+parseInt(parseInt(val.price_client) ))
 $('#sub-container'+key+' > div.card > div > div.card-text.sup-number-pr').html("<?php echo $this->lang->line("number of clients"); ?> :  "+val.premium_users)
                    
 $('#sub-container'+key+' > div.card > div > div.card-text.sup-months').html("<?php echo $this->lang->line("monthes"); ?>: "+val.months)
 $('#sub-container'+key+' > div.card > div > a').attr('title', val.name + '\xa0\xa0 ' + val.price)
                    
 $('#sub-container'+key+' > div.card > div > a ').attr ('href','https://api.whatsapp.com/send?phone=123456789&amp;text= val.name + val.price')

so the result that i got is like this : https://api.whatsapp.com/send?phone=123456789&text= val.name%20+%20val.price instead of something like this : https://api.whatsapp.com/send?phone=123456789&text= beginner package 90$

i already searched but not find anything

Misha
  • 7
  • 3
  • 2
    What "problem" are you referring to? What specific operation in the code shown isn't doing what you expect? – David Jun 28 '23 at 13:19
  • i want to set a button to redirect to whatsapp with message so i want to set href="https://api.whatsapp.com/send?phone=123456789&text= Hello, i want to ask about the package (val.name) with its price (val.price)" – Misha Jun 28 '23 at 13:21
  • Ok, and what specific operation in the code shown isn't doing what you expect? What specifically isn't working? – David Jun 28 '23 at 13:23
  • 2
    Have you tried just adding the text to the end of the `text=` url? It doesn't seem you you are trying to send anything at the moment (You will probably need to URL encode the string) – DBS Jun 28 '23 at 13:23
  • for me i can't set the message automatically via whatsapp, when i clicked at the button the url is still without message like this : https://api.whatsapp.com/send?phone=123456789&text= – Misha Jun 28 '23 at 13:25
  • @DBS i know, but how to set the correct message ? – Misha Jun 28 '23 at 13:26
  • @Misha: Look at the very last line of the JavaScript code you're showing us in the question. Look at the value being set to the `href` attribute. Why do you expect anything other than that exact value to be set to the `href` attribute? If you want to include additional text in that string, have you tried... including additional text in that string? – David Jun 28 '23 at 13:27
  • @David yes i tried this : $('#sub-container'+key+' > div.card > div > a ').attr ('href','https://api.whatsapp.com/send?phone=123456789&text=val.name + '\xa0' + val.price') – Misha Jun 28 '23 at 13:28
  • @Misha: Relevant code belongs in the question, not in comments. In the comment, that line of code appears to have typos and mismatched strings. If the problem is that you're getting a syntax error from typos and mismatched strings then the problem is merely a typo. (Note that you have *multiple* lines of code which successfully build concatenated strings, so it's not clear why you're not able to do that.) – David Jun 28 '23 at 13:31
  • 2
    This is starting to sound like what you really need is to do is go and read: [How to build/concatenate strings in JavaScript?](https://stackoverflow.com/questions/31845895/how-to-build-concatenate-strings-in-javascript) – DBS Jun 28 '23 at 13:31
  • @David everything works for me except the message , i can't show the package name and the package price – Misha Jun 28 '23 at 13:33
  • @Misha: Please update the question to show what you've tried and indicate what isn't working as expected. At the moment this appears to be nothing more than a typo from mis-matched string quotes. – David Jun 28 '23 at 13:34
  • for me the code has to show like this : https://api.whatsapp.com/send?phone=122345678&text=package name package price but i got the result like this : https://api.whatsapp.com/send?phone=123456789&text=val.name%20+%20val.price – Misha Jun 28 '23 at 13:35
  • 1
    @Misha which tells us you're not concatenating strings correctly. [Read this](https://stackoverflow.com/questions/31845895/how-to-build-concatenate-strings-in-javascript) – evolutionxbox Jun 28 '23 at 13:36

0 Answers0