Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

292
Views
How can i select a a tag and after pressing button i can go to specified href link

The code of a href link that comes dynamically from database

@foreach($doctor->tuesday as $tuesday)
<a class="timing" id="{{$tuesday->id}}" onclick="clicktime({{$tuesday->id}})" href="{{url('/')}}/fixschedule/{{$tuesday->id}}">
<span>{{date("g:i a",strtotime($tuesday->starttime))}}</span>
</a>
@endforeach

after select class name will be change to timing selected for blue highlight,

i want to select an a element like this

when i will press the button then the i want to redirect the specified link of a href and i want to select only one element at a time

code of button

<div class="submit-section proceed-btn text-right">
<a href="#" onclick="submit()" class="btn btn-primary submit-btn">Proceed to Pay</a>
</div>

i used here code of jquery that only one element can change now i want to go only redirected link after submit pressed

<script>
    function clicktime(id)
    {
      $("a").removeClass("timing selected");
      $("a").toggleClass("timing");
      document.getElementById(id).className = "timing selected";
    }
</script>
about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

First, prevent the a tag from redirecting with preventDefault();

@foreach($doctor->tuesday as $tuesday)
<a class="timing" id="{{$tuesday->id}}" onclick="preventDefault();clicktime({{$tuesday->id}})" 
href="{{url('/')}}/fixschedule/{{$tuesday->id}}">
<span>{{date("g:i a",strtotime($tuesday->starttime))}}</span>
</a>
@endforeach

then set the url on code of button like

<script>
function clicktime(id)
{
  $("a").removeClass("timing selected");
  $("a").toggleClass("timing");
  document.getElementById(id).className = "timing selected";
  $(".submit-btn").attr('href',$("#"+id).attr('href');
}
</script>
about 4 years ago · Santiago Gelvez Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!