I use the $_GET function to pull a value with php from the url (http:..../index.html?variable=value), basic stuff. However, I need to use that value in my form.
Typically, I would set
<?php echo 'value="'.$variable.'"' ; ?>
or something to that effect. However, I can't use php inside my form using the editor I'm working with.
Can I set a value in the form without using PHP in my form? If so, how?
Edit: with the CMS editor I'm using you can't store php code to the server. (I'm using FCKeditor. The same used by Dubral开发者_运维问答). This is a security measure all CMS's use even Wordpress. Basically I want to send/set the value in the form with php. Similar to how javascript does it: document.form.field.value
That looks completely valid to me. If you're using something like Dreamweaver, which is the only valid interpretation I can come up with, use a plain text editor instead of the editor you currently use. Problem solved.
There might be a more specific fix if you were to say what editor you're using, but since you don't, this is the best I can do. Just use Notepad or whatever.
The best way to set default values (ie pre-existing values) within an HTML form is as you mentioned in your question value="'.$variable.'"'.
If you are unable to use markup like that, then you may be able to use javascript (whether referencing a secondary file/feed using AJAX, or using the same variable echoing technique) to replace the values in the specific fields after the page has loaded.
ie
<script type="text/javascript">
document.form[0].name.value = "<?php echo $name; ?>";
</script>
You can set the value without php, but it has to be static value hardcorcoded in the html itself. For dynamic pages you have to use some programming language.
加载中,请稍侯......
精彩评论