views:

32

answers:

3
<textarea name="inputField" id="inputField" tabindex="1" rows="2" cols="40"onblur="DoBlur(this);" onfocus="DoFocus(this);" ></textarea>
<input class="submitButton inact" name="submit" type="submit" value="update" disabled="disabled" />
<input name="status_id" type="hidden">

the javascript(jquery):

function insertParamIntoField(anchor, param, field) {
       var query = anchor.search.substring(1, anchor.search.length).split('&');

       for(var i = 0, kv; i < query.length; i++) {
          kv = query[i].split('=', 2);
          if (kv[0] == param) {
             field.value = kv[1];
             return;
          }
       }
    }


$(function () {
    $("a.reply").click(function (e) {
       console.log("clicked");
       insertParamIntoField(this,"status_id",$("#status_id"));
       insertParamIntoField(this, "replyto", $("#inputField")[0]);


     $("#inputField").focus()

$("#inputField").val($("#inputField").val() + ' ');


     e.preventDefault();
       return false; // prevent default action
    });
});

the status_id parameter is not being passed:

post.php?reply_to=@muna&status_id=345667

it always give a value of zero, when its meant to give 345667

A: 

You don't have any id on the field, so when you try to set the value using $('#status_id') it won't put the value anywhere.

Add the id to the field:

<input name="status_id" id="status_id" type="hidden">
Guffa
thanks for the answer, i tried that but its giving zero!
getaway
A: 

add value to input

<input name="status_id" id="status_id" value="345667" type="hidden">
Praveen Prasad
A: 

You have two problems, the first @Guffa mentioned, you need an ID for $("#status_id") to work, like this:

<input id="status_id" name="status_id" type="hidden">

The other is here:

insertParamIntoField(this,"status_id",$("#status_id"));
insertParamIntoField(this, "replyto", $("#inputField")[0]);

Notice you don't have a [0] there, so you're setting .value on the jQuery object, not the element itself. Instead you need this:

insertParamIntoField(this,"status_id",$("#status_id")[0]);
insertParamIntoField(this, "replyto", $("#inputField")[0]);

Or change your method to use .val(), like this:

field.val(kv[1]);

And strip off the [0] calls so they're just

insertParamIntoField(this,"status_id",$("#status_id"));
insertParamIntoField(this, "replyto", $("#inputField"));
Nick Craver
once again you save the day!!! javascript guru
getaway