user2164063
user2164063

Reputation:

passing textbox values on the same page url without form or submit button using jquery or javascript

is there any ways to pass textbox values on the same page url without form or submit button i have javascript function but this function is working for drop down values not for text box values? i need to send textbox values on the same page url without form and submit button

now this is drop down page in this page dropdown values passing on the same page url but now i'm confused how can i send textbox values on the same page url without form or submit button using this javascript function?

function getComboB(sel) { 
var customers=document.getElementById("customers");
var value = sel.options[sel.selectedIndex].value;
addreceivable.action = "addreceivable.php?customers="+value+"";
addreceivable.submit();
}
<form name="addreceivable" id="addreceivable">
<select name="customers" id="customers">
<option value="Test">Test</option>
<option value="Demo">Demo</option>
<option value="Check">Check</option> 
</select>
<input type="submit" name="test" id="test" value="Submit">
</form>

now my problem is solved here i have completed my code passing textbox values on the same page url without submit button using javascript function

function getComboB(sel) { 
var textbox=document.getElementById("textbox");
var input_val = document.getElementById("textbox").value;
addreceivable.action = "test2.html?textbox="+input_val+"";
addreceivable.submit();
}

<form name="addreceivable" id="addreceivable">
<input name="textbox" class="textbox" onchange="getComboB();">
</form>

thanks to all friends!

Upvotes: 1

Views: 5884

Answers (2)

Tyler Hughes
Tyler Hughes

Reputation: 602

With textboxes use .val() to grab the value of it. I believe that is jQuery though so you might need that.

function getTextbox() {
   var textbox = $('input.textbox').val();
   //Do what you want with textbox now
}
<input name="textbox" class="textbox">

Upvotes: 1

Ryan
Ryan

Reputation: 5682

function getComboB(sel){
     //your other code
     //new code here
     var input_val = document.getElementById("id of your textbox").value;
}

You could use this to listen for changes in the text box:

document.getElementById("id of your textbox").addEventListener("change", getComboB);

The above line would listen for typing in the textbox and then call your function getComboB() at which point you would get the value of your textbox.

Upvotes: 0

Related Questions