Thread: variable scope

    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    56
    Rep Power
    11

    Unhappy variable scope


    I'm new to WML. I'm confused with the scope of variables.

    I thought that the variables are global to all cards in the same deck. But apparently it's not. Here's part of my code:

    <p>Please enter a course code:</p>
    <input name="course_code" size="9"/><br/>
    <anchor>Submit<br/>
    <go href="wml.cgi" method="post">
    <postfield name="action" value="submit_course"/>
    </go>
    </anchor>


    I didn't pass $(course_code) but in another deck, I tried to display $(course_code), and it was displayed correctly. How did it happened?

    thanks.
    oli
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Location
    Paris, France
    Posts
    375
    Rep Power
    11
    You should use something like

    <p>Please enter a course code:</p>
    <input name="course_code" size="9"/><br/>
    <anchor>Submit<br/>
    <go href="wml.cgi" method="post">
    <postfield name="action" value="submit_course"/>
    <postfield name="course_code" value="$(course_code)"/>
    </go>
    </anchor>
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    56
    Rep Power
    11
    I know I should include the line
    <postfield name="course_code" value="$(course_code)"/>

    but somehow even I didn't include it, $(course_code) is still passed correctly to another deck.
    That's why I'm confused.

    Also, if I used 'course' instead of 'course_code' as the name of the field, should the name of variable be '$(course)' or '$(course_code)'?

    If it's the latter one, what's the point of having the name?

    Thank you.
    oli

IMN logo majestic logo threadwatch logo seochat tools logo