0


I am a complete novice in jQuery and javascript, so if this sounds very silly or very simple thing to do please help me out with your expertise

$(document).ready(function(){
  $('#add_button').click(function(){
    var vol = $('input#cv').val();
    var col = $('input#cc').val();
    var comment = $('input#co').val();
    var sample = $('#cv').attr('class');
    var url = $('input#cv').attr('title');
    if( (vol && col && comment)  == ''){
      alert('No data to update');
    }else{
      url =  url.concat('volupdate=',vol,'&concupdate=',col,'&commupdate=',comment,'&sample=',sample);

      alert(sample + " " + vol + " " + col +" "+ comment +" " + url);
    }
  });
});

html :

my $correct_vol = qq{<input type="text" name="cv" id="cv" size="6" class="$sample_name" title="/here/is/where/you/are">};
my $correct_conc = qq{<input type="text" name="cc" id="cc" size="6" class="$sample_name" title="/here/is/where/you/are">};
my $comments = qq{<input type="text" name="co" id="co" size="10" class="$sample_name" title="/here/is/where/you/are">};
my $update = q{<input type="submit" value="Update" id="add_button" class="add_now">};

These forms the last four columns in a big table.
My question is: How should I return the url in jquery function to my perl?
if I use return url what should I expect ? And how should I handle the values passed from the url in my script? Thanks for your suggestions.

1 Answer 1

1

Your javascript code won't connect with your perl code by itself. The connections to perl will happen as it processes the form elements. So your values need to be passed via POST or GET, the same way they would be passed if you were doing this in an HTML + perl only solution.

What you can do in your javascript is to set the value of the form input that you need to pass. That would be accomplished via something like $("#inputElementID").val(url); (assuming that you give the input element an id of inputElementID in the html where you create it.

You could also submit the form through javascript, if it made sense to do so.

As to using return url, that will only end up returning the value of url to the javascript function that calls it (which, in this case, doesn't really exist since this is a document.ready() execution.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.