简体   繁体   English

如何在不提交的情况下从文本框和下拉列表中获取值

[英]How to get the value from textbox & dropdown without submit

I want to pass the value of product id, product name, textbox & drop down to 'addtocart.php' page. 我要传递产品ID,产品名称,文本框的值,并下拉至“ addtocart.php”页面。 Only values I managed to get are id & name. 我设法获取的唯一值是ID和名称。 If I use form for these then values of product id & name are not submitting. 如果我使用这些表格,则不会提交产品ID和名称的值。 Can anyone help sending values of textbox & dropdown as well? 任何人都可以帮助发送文本框和下拉菜单的值吗?

while ($row = @ mysql_fetch_array($results)){

                print
                "<div class= 'item'>" .
                "<p>Product id ".$row["id"]."</p>".
                "<p><img src=".$row["image_location"]." class='masterTooltip' id='b7' title='Double click on image to make as favorite' ondblclick='openlink({$row["id"]})'></p>".
                "<p>&pound".$row["price"]."</p>".
                "<p>".$row["name"]."</p>".
                "<p>".
                "Qty:&nbsp;&nbsp;&nbsp;<input type='text' id='quantity' name='quantity' style='width: 20px; height:14px;'>".
                "&nbsp;<select name='type'>".
                "<option value='KiloGrams'>KiloGrams</opstion>".
                "<option value='Bunch'>Bunch</option>".
                "</select>".
                "<p>".      
                "<a href='addtocart.php?id={$row["id"]}&name={$row["name"]}' class='button' id='b1'> Buy Now</a>".
            //  "&nbsp;&nbsp;<a href='addtofavorite.php?id={$row["id"]}&name={$row["name"]}' id='heart'></a>".
                "</p>".
                "</div>";

对于那些不在任何其他输入中但要发送到服务器的字段,您需要使用<input type='hidden' name='your_field_name' value='your_field_value' />表格。

You want to use ajax, I don't know if used it before but it works like this; 您想使用ajax,我不知道以前是否使用过它,但它的工作原理如下: First you need to listen change event then send request to server; 首先,您需要监听更改事件,然后将请求发送到服务器;

$( "#type" ).change(function() {
 $.ajax({
      url: "test.php",
      context: this.val()
       }).done(function() {
            alert("it worked");
            });
       });

I hope you I could express it well. 我希望你能表达得很好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从数据库获取文本框中的值取决于没有提交按钮的下拉列表 - How to get the value in Textbox from database depends on dropdown list without submit button 如何从下拉列表中获取选定的值并在查询中使用它而不单击提交? - How to get the selected value from dropdown and use it in query without clicking submit? 如何在不使用提交的情况下从下拉列表中选择值 - How to select value from dropdown without using submit 获取选定的下拉列表而不提交按钮 - Get Selected Value of dropdown without submit button 获取没有提交按钮的选定下拉值 - get selected dropdown value without submit button 如何从下拉列表中获取值并将其用作表单提交ID - How to get the value from a dropdown list and use it as a form submit id 将值从第一个下拉列表提交到第二个下拉列表而不重新加载页面 - Submit value from first dropdown to second dropdown without reloading the page 如何在不使用提交的情况下在php中提交下拉框值 - How to submit a dropdown box value in php without using submit 如何在Laravel中获取选定的提交下拉列表值? - How to get the selected dropdown value on submit in Laravel? 从自动完成文本框中选择值时如何在不单击提交的情况下进行重定向? - How to redirect while select value from autocomplete textbox without click on submit?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM