Jump to content

AV1611

Members
  • Posts

    997
  • Joined

  • Last visited

Posts posted by AV1611

  1. Thank you.

     

    Unfortunately the tutorial doesn't answer my question.

     

    1. I don't know AJAX

    2. While I know many disagree, I don't need to use jQuery, and have no idea how to use it. Please let's don't argue about that.

    3. When I fill in the initial < input type = text >  I assume I need to do onChange = myFunction()

    4. so I really need to know how to write myFunction. I can write the PHP script that gets queried by myFunction.

     

    Your tutorial, aside from using Jquery which I don't really understand, drives a pulldown from another pulldown , I think...

    I am 6 months into this project, and don't really want to change to jQuery at this point.

  2. Ok,

     

    I have NEVER tried to use AJAX before.

     

    I have a web application that requires the user to select an item from a pulldown.

     

    The first input is a Lot number.

     

    The info to build the select list is generated via an MySQL query.

     

    Now, here's the thing.

     

    There are MANY items in the pulldown (1,000) which is not practical.

     

    I would like to run a query modified by the string they put in the first input box. I'm trying to avoid a page reload.

     

    So,

     

    Here is the input box

     

    <input name="lotno" />

    Here is the basic pulldown code:

     

    echo "<option value='void'>--- Select a test ---</option>";
    $sql='SELECT distinct `test_templates`.`tempid`, concat(`test_templates`.`assy`," - ",`test_templates`.`testdesc`) as Description
    FROM `test_templates` ORDER BY `assy` ASC';
    $result = mysql_query($sql);
     while($row=mysql_fetch_array($result)){
     echo "<option value='".$row[0]."'>";
     echo $row[1];
     echo "</option>";
     }
    }

     

    I would change the above SQL with ...WHERE `lot` like WHATEVER IS IN THE lotno input field.

     

    Then the result of the query would be very limited.

     

    Thanks in adanced.

     

     

  3. How do I "split" the value?

     

    <input value="12-99"...>

     

    I want the substring 12 in the first input field and 99 in the second input field.

     

    You can use split():

     

    var parts = someval.split('-');
    // parts[0] now contains "12"
    // parts[1] now contains "99"

     

    is document.formName.inputName1.substring(someval(0,1)) (not sure of the JS syntax) valid?

     

    Not quite. You want to select a sub-string of someval; currently you're trying to select it from the input's DOM object. With the parts array though you don't need to use substring:

     

    document.formName.inputName1.value = parts[0];
    document.formName.inputName2.value = parts[1];

     

    Thanks for helping. One final little question. If parts[0] corresponds to a pulldown rather than a text input, would it still work?

     

    Apple <----value=1

    Banana <--Value = 2

    Frog<-------Value = 3

     

    ??

     

  4. thank you for the reply.

     

    How do I "split" the value?

     

    <input value="12-99"...>

     

    I want the substring 12 in the first input field and 99 in the second input field.

     

    is document.formName.inputName1.substring(someval(0,1)) (not sure of the JS syntax) valid?

  5. Let me start by saying I don't know JS. I only know PHP/HTML.

     

    That being said, I have a form with 2 input fields. I have a button. I want to press the button and have it autopopulate the two input fields.

     

    example.

    button: [12-84]<--- click this and input 1 now has a 12 and input 2 now has an 84 in it. They can also manually enter the date in the fields.

     

     

     

    I know I can do

    <script>

    function transferField(someval){

    document.form.code.value = someval;

    }

    </script>

    <input button id=code onclick="transferField(this.value)"....>

    blah blah...

     

    but that only does a single field. I want the one button click to do to values to two seperate input fields.

     

    Thanks :)

     

  6. Ok, so I need a form to validate that the data entered was a 10 digit number ONLY. It must be a number and it must be 10 digits.

     

    if(!eregi("[0-9]{10}",$str)) echo "Invalid Serial Number";

     

    Is this right?

  7. You guys are awesome... I was trying to get the final answer (please don't laugh too loud... it would have worked... but I didn't get part of it right...) anyways, here's my crappy approach. Remember, I don't know regex, but I can improvise LOLOL

     

    $string = "CX1,CX2-6,CX7,CX9-CX11";

    preg_match('~([a-z]+)(\d+)(?:-(\d+))?~i',$string,$parts);

    $prefix = $parts[1];

    $string=str_replace(" ","",$string);

    $string=str_replace($prefix,"",$string);

    $string = explode(",",$string);

    $c=count($string);

    $i=0;

    while($i < $c){

    $s=explode("-",$string[$i]);

    $ct=count($s);

    $ci=0;

    while($ci < $ct){

    echo $prefix . $s[$ci] . "<br />\r\n";

    $ci++;

    }

    $i++;

    }

     

  8. Oops... one last problem...

     

    The data is coming from a VERY old database, and the data syntax is not always the same. The following is possible:

    $str="CX1,CX2-6,CX7,CX9-CX11";

     

    They did CX2-6, then later CX9-CX11. That seems to be a small issue as well... I am so sorry...

  9. You aren't going to be solving this using regex, at least not all of it. You're going to need to explode the values using the , then us a regex to match the 2-5, then use a for loop to iterate over the values and add them correctly to the array

    I figured I would have to explode the "," then the -... but how do I get the "alpha" character, seeing it may be 1-3 characters long? i.e. R, C, CX, etc...?

    Maybe something that does "grab the beginning of the string until you encounter a number"? How do I do that?

  10. First, hello to those who may remember me from YEARS ago :P

     

    Anyways, after all these years, I still suck at regex, so here's a real world problem I need help with:

     

    Query returns something like this:

     

    C1,C2-6,C7,C14,C15-43

     

    or:

     

    C1,C2-C6,C7

     

    or:

     

    CX1,CX2-15

     

    or:

     

    R1,R2-5,R7

     

    etc...

     

    Anyways, I need to convert to this format: (I will use the last example)

    R1,R2,R3,R4,R5,R7

     

    I can use array or whatever, I just don't know how to do the regex to do it...

     

    And before I get asked for code, here is what I have so far LOL...

     

    <?php

    $str="R1,R2-5,R7";

     

    ?>

  11. Ok, I have a log file that is written to. I only want the text file to have the last fifty lines (\n) delimited

     

    So, how do I make it delete the excess from the TOP of the file?

     

    So if it had 60 lines, I would want it to only have lines 10-60 to net 50 total.

     

    Thanks.

     

  12. One last question before I can mark my problem solved and I'll post my code when I'm done to help others...

     

    In the multi array, the sub arrays are numbered.  The array themselves are not numbers

     

    $array['Name'][0]

    $array['Name'][1]

    $array['Name2'][0]

    $array['Name2'][1]

    ...

    and so on

     

    I know that $array['Name'] is the name of the element, but is there a way to echo the element name?

     

     

  13. First, long time no see for those who remember me :)

     

    I have a question about foreach loops and arrays.

     

    I know how to foreach the elements of an array

     

    $array=array("a","b","C");

    $i=0;

    $c=count($array);

    while($i < $c){

    //do something with element $array[$i]

    $i++;

    }

     

    that's just an example but I want to be able to do it with a multi array:

     

    $array=

    a[0]item

    a[1]item

    a[2]item

    b[0]item

    b[1]item

    b[2]item

     

    so I want to foreach the $array[]

    then while that's going I want to foreach the $array[][] within that.

     

    foreach $array[]{

        foreach $array[][]{

          }

    }

     

    Not sure how to do that.

     

    wow, hope that makes sense

  14. Thank you for your replies.

     

    As I don't know anything about JS or Ajax, I don't think I can go further unless someone gives me more help...

     

    Am I correct that if I set a session variable in the popup script (popup.php) that I cannot read that variable from index.php because it's a different browser instance?

     

  15. I'm starting here because I believe this is a PHP question but maybe not?

     

    ok,

     

    when you start index.php, as popup page opens, called page2.php.

     

    The popup plays music via a flashplayer... not important.

     

    So, I need a way to monitor from index.php if the popup is still open or if they closed it.

     

    I gather that sessions cannot be shared between the popup and the main page.

     

    So, is there a way?

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.