This topic is locked

Hidden Fields

10/15/2007 10:00:32 AM
PHPRunner General questions
D
drh author

Hello forum.
I have an application written using PHPR 3.1 and I need to be able to access the value of a hidden field in the edit program.
Basically, I have 2 fields Principal (current principal) and O_Principal (original principal). When a new record is added, the same value is stored in both fields. Principal is an editable field and O_Principal is hidden. The user is allowed to reduce the Principal, but not increase the amount (Principal) from the original value (O_Principal).
I thought I could do this using a javascript after the user pressed "save". The javascript would do the comparison and if the edited value was greater than the original value (O_Principal) I would have an alert box notifying the user that the edited value was not allowed. The field would go back to the previous value and the user given another chance to change the Principal to an acceptable value.
Since the O_Principal field is hidden, its value is not available on the web page, so my javascript will not work. Is there a way to place the O_Principal value on the page so it is available to my javascript without being displayed to the user? Or is there a much better way to do this?
Any thoughts or advice are greatly appreciated.
Thanks,

Dave

Alexey admin 10/15/2007

Dave,
hidden field values are available to Javascript.

Access them the same way as text boxes.

D
drh author 10/15/2007

Alexey,

thank you for the quick reply.
Could you please be more specific, I do not understand what you mean. Am I suppose to access the value in an event? Please keep in mind this is a PHPR 3.1 application.
Thanks,

Dave

Sergey Kornilov admin 10/15/2007

Dave,
are you talking about events or about accessing hidden field values via Javascript?

D
drh author 10/15/2007

Sergey,

at first I thought that the way to check that the user did not increase the dollar amount value in Principal greater than what is in the O_Principal was to use javascript. However, since O_Principal is a hidden field, I don't think I can access the value by using a javascript. Please advise me if this is incorrect. If there is a way to access this hidden field using a javascript, how would I do it.
Since I don't think I can get the value in a javascript, I thought maybe I could use an event to do the checking. However, I am not exactly sure if that is the proper way.
When Alexey said to access it just like a text field, I guess I thought of events, but I did not understand exactly what was meant and asked for clarification.
Thanks,

Dave

Sergey Kornilov admin 10/15/2007

When you saying you cannot access hidden field value via Javascript you are wrong.

You can access the hidden field value exactly the same way as you access regular, non-hidden field i.e. a text field.
I hope this makes sense.

D
drh author 10/15/2007

Sergey,

thanks for the reply. What I mean is in order to access a value using javascript, I open the web page in my browser to the edit a record program and view the page source. I scroll down and find the line corresponding to my field.
In this case Principal:

<tr><td class=shade>Principal </td><td><input type="text" name="value25" value="">&nbsp;<img src=images/icon_required.gif></td></tr>
i see that it is value25 so I can use value25 in my javascript to access the data in Principal.
Now when I try this with O_Principal which is a hidden field. I scroll down through the page source to find O_Principal, it does not exist on the page. So I do not think I can set O_Principal as a hidden field. If I make it a Text field, then it is displayed on the edit page to the user, which I do not want.
I do not see how I can access O_Principal from a javascript. If I am wrong, and I can still get the value from a javascript, please let me know how to do it.
Otherwise, do you know of a different way to accomplish the task?
Thanks

Dave

Alexey admin 10/17/2007

Dave,
look for this tag

<input type="hidden" name="valueNN" value="">

in the code.

Where NN is an ordinal number of your O_Principal field in SQL query.
If you having difficulties with this you can contact support team directly at support@xlinesoft.com

D
drh author 10/26/2007

Sergey and Alexey,

finally got back to work on this problem. My bad. I can access the hidden fields using javascript just like any other field on the page. Guess I just didn't scroll over far enough when viewing the page source. <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=22636&image=1&table=forumreplies' class='bbc_emoticon' alt=':(' />
Thanks for your patience and support.
Dave