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

ⅰ亾dé卋堺 提交于 2019-12-24 15:09:44

问题


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!


回答1:


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">



回答2:


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.



来源:https://stackoverflow.com/questions/15712596/passing-textbox-values-on-the-same-page-url-without-form-or-submit-button-using

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!