Can you explain a little bit more for me...

You're saying that (for example)..

instead of

1 <? print ("\"this\" is a test"); ?>

It'd be better as...

1 <?
2 $form == "this" is at test
3
4 print ($form);
5 ?>

Tried that... I get an error on line 2 (I placed the line numbers ahead for clarification).

How should I word the variable ($form) so that the quotes are left as quotes and not screwing things up? I think that's what's wrong in my original php script.

Thanks in advance,

B.

    fiddled around with it...

    In order to get ANY output instead of errors, I'd have to still mess with the quotation marks by making the example code...

    <?
    $text = ("\"this\" is a test");

    print ($text);
    ?>

    "this" is a test

    is what is the output... Adding the \ in front of the quotes I believe is the problem with the javascript in my original post and causing the javascript to fail.

    Any suggestions?

    Thanks for the help.

    B.

      Hmm... forgive me if I misunderstood, but why is it necessary to lump this whole HTML page into a PHP print() call if you aren't actually doing anything that requires PHP?

        The php form itself is being used as part of a larger page as an include function. I have everything else working properly, just getting the javascript validation script working inside it is becoming a hastle..

          Most of the time when I have javascript in PHP I have to use \". For whatever reason javascript seems to want this...it looks like you got that. Like...

          <a href='some.php' onClick=\"return confirm('Yes or no');\">Yep</a>
          

          Edit: well, this forum kind of bunks up the example but you get the idea...

            Your example would not work as that line would have an error in it...

            <a href='some.php' onClick="return confirm('Yes or no');\">Yep</a>

            should be...

            <a href='some.php' onClick=\"return confirm('Yes or no');\">Yep</a>

            and I've already thought of and tried it. The placing of the \ in front of the " from inside the php print(""); command is what I think is screwing up the javascript in the first place. I have no idea how to correct this..

            Maybe if the javascript itself could be made into a .js file & then simply called upon from the php & form? (and I don't know how to do that, either.) 😕

            Otherwise, I'm stumped.

            Thanks for the advise,

            B.

              I just figured out how to make the javascript into a .js file and modified the php, but it still doesn't work...

              I'll keep plugging away..
              B.

                Ok. Looking with a little more atention to code I noticed that you are using inverted quotes.

                You have

                alert('Please enter a value for the '\" + fieldLabel + \"' field.'); 
                

                So you're putting the double quotes outside your code.

                It should be

                alert('Please enter a value for the \"' + fieldLabel + '\" field.'); 
                

                You have it in function validRequired
                and if(!isn), so far I've seen.

                  Javascript debugging hint:

                  Any time more than 1 element on a form shares the same name or id, javascript form functions fail.

                  Example

                  <form name=test onsubmit=checkme()>
                  <input type=text name=x>
                  </form>

                  checkme() will be ok.

                  <form name=test onsubmit=checkme()>
                  <input type=text name=x>
                  <input type=text name=x>
                  </form>

                  checkme() will fail. (In IE without an error message)

                  Sometimes elements you create duplicate names without realizing.

                  Just another thing to check.

                    I haven't fixed the error... just found a work-around... 😃

                    I've made an IFRAME using php & calling an html page inside of the iframe.

                    Once the full page loads, everything works flawlessly.

                    Until I find out how to do it inside the php itself, it'll do... 🙂

                    Thanks for the help.

                    B.

                      When they told you to compare the too you said that it goes into an email. What they meant was you have the html code and when you bring up the php page before hitting the submit button do a view source. This should be the same as your html code if not something isnt working correctly.

                        Write a Reply...