Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3229104
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:46:19+00:00 2026-05-17T16:46:19+00:00

Ok so i have this javascript function getpreconfigproducts(str1,str2) { var url=ajax_preconfig_products.php?; url=url+id=+str1+&cid=+str2; xmlHttp =

  • 0

Ok so i have this javascript

function getpreconfigproducts(str1,str2)
{
var url="ajax_preconfig_products.php?";
url=url+"id="+str1+"&cid="+str2;
xmlHttp = GetXmlHttpObject(stateChangeHandler);
xmlHttp_Get(xmlHttp, url);
return false;
}

and it calls this php

<?php 
if($_GET['id']!='')
{
   $sql="SELECT * FROM productinfo WHERE ProductID=".$_GET['id']." AND Status=1";
   $pro=ExecuteGetRows($sql);
?>
<p>Qty: <input type="input" name="qty[]" id="fpro[]" value="1" style="width:15px; margin-top:-3px;" /> <label><?php echo $pro[0]['ProductName'];?></label> </p>
<?php 
        echo "^_^";
        echo ",".$pro[0]['ProductID'];
    } ?>

which generates this

<div class="fields">
<h2>Final Products</h2>
<p id="finalproductsid">
  <p>Qty: <input name="qty[]" id="fpro[]" value="1" style="width: 15px; margin-top: -3px;" type="input"> <label>FIREBOX S5510 15</label> </p>
  <p>Qty: <input name="qty[]" id="fpro[]" value="1" style="width: 15px; margin-top: -3px;" type="input"> <label>FIREBOX S5510 15</label> </p>
</p>
</div>

The problem is that if a user changes the input qty[] to say 5 and adds another product it reverts back to 1 …any ideas how i can address this

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T16:46:19+00:00Added an answer on May 17, 2026 at 4:46 pm

    Aside from all the SQL injection stuff, mentioned already, I think I might know what your problem is. Tell me if I understand your script:

    1. User clicks an ‘add product’ button
    2. Button fires an AJAX request to the PHP script above
    3. The PHP script generates some HTML
    4. Somehow (?) the generated HTML gets displayed
    5. The values of all of the other product fields in the form revert back to one

    I’m assuming #4 is where the problem (#5) is occurring. Depending on how you append the HTML to the form, the input fields will sometimes revert. For instance:

    //Reverts all form inputs to default-
    myForm.innerHTML += "<input name='new_input'/>";
    //Keeps current input values-
    var newNode = document.createElement('input');
    myForm.appendChild(newNode);
    

    May I suggest, that instead of appending a string of HTML, you create the HTML with JavaScript, getting the product name/id through an AJAX request.

    I don’t quite understand how your script is working though. As far as my limited knowledge goes, the PHP isn’t displaying onto the current page, but echoing to the AJAX’s response text. Is there something more, or is it just me?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a JavaScript function, pop_item . I have to call this from PHP,
I have this JavaScript function: Contrl.prototype.EvaluateStatement = function(acVal, cfVal) { var cv = parseFloat(cfVal).toFixed(2);
Hi i have this javascript function function test(){ var count = 0; var date1
So for example I have a structure like this: Javascript function toggle(id){ var element
I have this function in my Javascript Code that updates html fields with their
I'm hopeless at Javascript. This is what I have: <script type=text/javascript> function beginrefresh(){ //set
Ok, I have one JavaScript that creates rows in a table like this: function
I have this javascript function that block special characters... function validaTexto(texto) { !(/^[A-zÑñ0-9]*$/i).test(texto.value) ?
I have this JavaScript function which is working in all the machines I tried
I have this javascript function myFunction(source) { window.open(source, Title, 'width=400, height=400'); } and in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.