ユーザーがローカル ファイルとリモート ファイルをインポートできるようにしていますが、単一の入力を使用して両方のケースを処理するにはどうすればよいですか?
Stackoverflow のように、タブを使用して実行できます。
または、次のようなラジオ ボタンを使用します。
<style>
.displayNone {
display:none;
}
</style>
<form action="test.php">
File type:
<input id="radio-url" name="type" type="radio" checked value="url" /> URL
<input id="radio-file" name="type" type="radio" value="file" /> File
<div id="url">
<input name="url" type="text" />
</div>
<div id="file" class="displayNone">
<input name="file" type="file" />
</div>
<input type="submit" value="Send" />
</form>
<script type="text/javascript">
$('#radio-url').click(function() {
$('#url').removeClass('displayNone');
$('#file').addClass('displayNone');
});
$('#radio-file').click(function() {
$('#file').removeClass('displayNone');
$('#url').addClass('displayNone');
});
</script>
切り替え可能な :
しかし、どうすればそのようなフィールドを作成できますか:
リモートホストでファイルを処理する方法は重要ではないという質問全体に注意してください。