Jump to content

Reg Edit

Members
  • Content Count

    411
  • Joined

  • Last visited

Community Reputation

0 Neutral

About Reg Edit

  • Rank
    Member

Profile Information

  • Location
    UK
  1. Yes you can, but not more than once with the same name! A variable declaration is global in your page (unless withina function). So in your example you would either need to reuse the same variable without declaring it again:<%dim namename="Donald Duck"response.write("My name is: " & name)%><%name="Darkwing Duck"response.write("My name is: " & name)%> or alternatively, in cases where you need a separate variable, declare it with a different name: <%dim namename="Donald Duck"response.write("My name is: " & name)%><%dim name2name2="Darkwing Duck"response.write("My name is: " & name2)%>
  2. It's Flash you need to look at: http://www.w3schools.com/flash/default.asp
  3. The approach is fine, now you just need a way to discern which state you are dealing with: either the page is being rendered for the first time (so Set A needs rendering), or a form has been submitted (so a different set needs rendering instead). I've given an example below of how you could do this. You can count the number of elements in the $_POST array to find out whether it's a postback:if (count($_POST)==0){ // Nothing's been posted: initialise page by rendering A. print '1. what do you choose? <br /><br /> <input type="radio" name="r1" value="b" /> B <br /> <input type="radio" name="r1" value="c" /> C <br /> <br /> <input type="submit" name="submitA" /><br /><br />';}else{ // Something's been posted. See what to render next instead of A. if ($_POST['submitA']) { // A submitted: render B or C. (Example renders B only for simplicity) echo 'This is B<br>'; echo '<input type="submit" name="submitB" />'; } else if ($_POST['submitB']) { // B submitted: render Z. // (Other Z details here) echo 'This is Z<br>'; echo '<input type="submit" name="submitZ" />'; } else if ($_POST['submitZ']) { // Z submitted echo 'The end'; }} In this example I've given the submit buttons different names (submitA etc) to tell which state we're in. As to the javascript/php question, both are well worth learning as they are both needed for different things (javascript for client-side scripting, and php for server-side scripting).
  4. On the other hand, if you're doing it in php, your php logic just needs to avoid emitting the html for Set A at those times. Either way, sounds like good progress already. You just need to finish the logic to only display part A when appropriate. If that's giving you trouble, post the code here so we can suggest a fix.
  5. As you want to submit after each choice, then yes, you can do it with php using the same page. Using php, the html contents of that page are dependent on your php code, and you can include logic in that code that looks at what's been submitted and emits the next question. So rather than hiding page content, it becomes a question of deciding page content.You'll need to look at the details of exactly how you want to do this, but the rough idea is to examine the form fields submitted: and if A has been submitted with the first radio button selected, write out the html for B, but if it's the other radio button, write out the html for C instead. Should be a useful php learning exercise for you!
  6. Well, the data really should be persisted as two separate columns. However, if you insist, you can do it with a query such as the one below, but it's not a very good practice in my opinion! Also it is subject to problems if any data is inconsistent.In this example the table is categories, and the two words are in the description column: SELECT description, right( description, length( description ) - locate( ' ', description ) ) rhtextFROM categoriesORDER BY rhtext
  7. I have now seen PHP_SELF used in different ways and also now read that it may not be reliable. I have also seen it as $_SERVER[php_SELF] which is different from what I saw before.As a test, try hard-coding the URL for both hrefs: http://www.jadvyga.lt/?language=lt http://www.jadvyga.lt/?language=en Assuming you get that working, you can then sort out the right function for deriving the URL afterwards.
  8. The problem is that by using if/else, you are adding more and more to the query string every time after the first time, so it can become ?language=en&language=lt&language=en&language=lt That's why I suggested PHP_SELF plus ? every time. I think it should work. What problem are you having?
  9. You need to maintain some kind of context for the user's current session, and refer to it when the page loads, so that you can set the filters correctly for the current state. Assuming this is classic ASP, you should probably use ASP session variables for this. (If it's ASP.NET there are other ways such as viewstate and controlstate which you should look into.)
  10. Sorry, I missed that... I think you don't need the if statement any more. So instead of if (count($HTTP_GET_VARS)==0) echo getenv('PHP_SELF')."?language=lt"; else { echo getenv('PHP_SELF')."&language=lt"; } you would just need echo getenv('PHP_SELF')."?language=lt"; and the same for the other if statement.WARNING: php is something I am only just learning myself!!! I mainly use MS stuff.
  11. Reg Edit

    strpos nightmare

    The negation is getting evaluated at the wrong place. Use !== instead of !strpos:if (strpos($vPSA, "crue")!==false) ...
  12. Reg Edit

    strpos nightmare

    Have you checked the code that calls this function? I think you may find the problem there. Not knowing the details of how you get the value from your comma-separated list, perhaps you are doing a loop starting from 1 instead of 0, or that kind of thing, missing the first value, so your function is never called with "canc".Try hard-coding a call to the function passing the value "canc", to test your function in isolation from the calling code.
  13. A couple of points: - don't embed an element with an onclick handler within an anchor; use either onclick or href, not both. - don't append a querystring variable to the full URI since that already contains a querystring. You are appending more and more text such as ?language=en?language=it to the URI.Try the following, which usees PHP_SELF instead of REQUEST_URI, and doesn't need the javascript function since the href takes care of the click event: echo "<a href=\""; if (count($HTTP_GET_VARS)==0) echo getenv('PHP_SELF')."?language=lt"; else { echo getenv('PHP_SELF')."&language=lt"; } echo "\" ><img src=\"images/lt_flag.gif\" border=\"1\"></a> <a href=\""; if (count($HTTP_GET_VARS)==0) echo getenv('PHP_SELF')."?language=en"; else { echo getenv('PHP_SELF')."&language=en"; } echo "\"><img src=\"images/en_flag.gif\" border=\"1\" /></a>"
  14. If you want the position of the current node, use boen_robot's example. If you want the value of the current node, use my example. If still stuck please can you explain what you need the xsl to achieve.
  15. Watch out for the typo in that line ("sting"); however, I think you may mean <xsl:when test=". = '$sql'"> to test the value of the node at the current position.See also http://www.w3schools.com/xsl/xsl_choose.asp.
×
×
  • Create New...